* @author Allcreator Co., Ltd. * @link http://www.netcommons.org NetCommons Project * @license http://www.netcommons.org/license.txt NetCommons License * @copyright Copyright 2014, NetCommons Project */ App::uses('AppHelper', 'View/Helper'); /** * Question edit Helper * * @author Allcreator Co., Ltd. * @package NetCommons\Registrations\View\Helper */ class QuestionEditHelper extends AppHelper { /** * Other helpers used by FormHelper * * @var array */ public $helpers = array( 'NetCommonsForm', 'Form' ); /** * 質問属性設定作成 * * @param string $fieldName フィールド名 * @param string $title 見出しラベル * @param array $options INPUT要素に与えるオプション属性 * @param string $label checkboxの時のラベル * @return string HTML */ public function questionInput($fieldName, $title, $options, $label = '') { $ret = '
'; $type = $options['type']; if ($this->_View->viewVars['isPublished']) { $disabled = 'disabled'; $options = Hash::remove($options, 'ui-tinymce'); } else { $disabled = ''; } if ($type == 'checkbox') { $ret .= '
'; //} $ret .= '
'; return $ret; } /** * 登録フォーム属性設定作成 * * @param string $fieldName フィールド名 * @param string $label checkboxの時のラベル * @param array $options INPUT要素に与えるオプション属性 * @param string $help 追加説明文 * @return string HTML */ public function registrationAttributeCheckbox($fieldName, $label, $options = array(), $help = '') { $ngModel = 'registrations.registration.' . Inflector::variable($fieldName); $ret = '
'; $ret .= '
' . $this->NetCommonsForm->error($fieldName, null, array('class' => 'help-block')) . '
'; $ret .= '
'; return $ret; } /** * 登録フォーム期間設定作成 * * @param string $fieldName フィールド名 * @param string $label checkboxの時のラベル * @param array $minMax 日時指定の範囲がある場合のmin, max * @param string $help 追加説明文 * @return string HTML */ public function registrationAttributeDatetime($fieldName, $label, $minMax = array(), $help = '') { $ngModel = 'registrations.registration.' . Inflector::variable($fieldName); $options = array('type' => 'text', 'id' => $fieldName, 'class' => 'form-control', 'placeholder' => 'yyyy-mm-dd', 'show-weeks' => 'false', 'ng-model' => $ngModel, 'datetimepicker', 'datetimepicker-options' => "{format:'YYYY-MM-DD HH:mm'}", 'show-meridian' => 'false', 'label' => $label, 'div' => false); if (! empty($minMax)) { $min = $minMax['min']; $max = $minMax['max']; $options = Hash::merge($options, array( 'min' => $min, 'max' => $max, 'ng-focus' => 'setMinMaxDate($event, \'' . $min . '\', \'' . $max . '\')', )); } $ret = $this->_View->element('NetCommons.datetimepicker'); $ret .= '
'; $ret .= $this->NetCommonsForm->input($fieldName, $options); if (!empty($help)) { $ret .= '' . $help . ''; } $ret .= '
'; return $ret; } }