BcFormHelper::jsonList PHP Method

jsonList() public method

JsonList
public jsonList ( string $field, string $attributes ) : array
$field string フィールド文字列
$attributes string
return array 属性
    public function jsonList($field, $attributes)
    {
        am(array("imgSrc" => "", "ajaxAddAction" => "", "ajaxDelAction" => ""), $attributes);
        // JsonDb用Hiddenタグ
        $out = $this->hidden('Json.' . $field . '.db');
        // 追加テキストボックス
        $out .= $this->text('Json.' . $field . '.name');
        // 追加ボタン
        $out .= $this->button('追加', array('id' => 'btnAdd' . $field));
        // リスト表示用ビュー
        $out .= '<div id="Json' . $field . 'View"></div>';
        // javascript
        $out .= '<script type="text/javascript"><!--' . "\n" . 'jQuery(function(){' . "\n" . 'var json_List = new JsonList({"dbId":"Json' . $field . 'Db","viewId":"JsonTagView","addButtonId":"btnAdd' . $field . '",' . "\n" . '"deleteButtonType":"img","deleteButtonSrc":"' . $attributes['imgSrc'] . '","deleteButtonRollOver":true,' . "\n" . '"ajaxAddAction":"' . $attributes['ajaxAddAction'] . '",' . "\n" . '"ajaxDelAction":"' . $attributes['ajaxDelAction'] . '"});' . "\n" . 'json_List.loadData();' . "\n" . '});' . "\n" . '//--></script>';
        return $out;
    }

Usage Example

Example #1
0
 /**
  * JsonList
  * TODO 確認画面用の実装は全くしてない
  * 
  * @param string $fieldName フィールド文字列
  * @param array $attributes html属性
  * @return string	htmlタグ
  * @access public
  */
 public function jsonList($fieldName, $attributes)
 {
     if ($this->freezed) {
         $out = '';
         if (!empty($this->request->data[$fieldName])) {
             $out = '<div id="JsonTagView"><ul class="freezed">';
             foreach ($this->request->data[$fieldName] as $tag) {
                 $out .= '<li>' . $tag['name'] . '</li>';
             }
             $out .= '</ul></div>';
         }
         return $out;
     } else {
         return parent::jsonList($fieldName, $attributes);
     }
 }