本文整理匯總了PHP中type::addElement方法的典型用法代碼示例。如果您正苦於以下問題:PHP type::addElement方法的具體用法?PHP type::addElement怎麽用?PHP type::addElement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類type
的用法示例。
在下文中一共展示了type::addElement方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: edit
/**
* First step. Adding initial data.
*
* @param type $form
* @param type $request
* @param type $config
* @return type
*/
public function edit($form, $request, $config)
{
$form->addElement(new Element\HTML('<legend>' . Container::get('params')->langArray['creation_new_conf'] . '</legend>'));
$form->addElement(new PdfCKEditor('', 'body', array('value' => $request->request->get('pdf'))));
$this->addControls($form, $request);
return $form;
}
示例2: setHierarchy
/**
* Second step. Setting question structure.
*
* @param type $form
* @param type $request
* @param type $config
* @return type
*/
public function setHierarchy($form, $request, $config)
{
$disciplineId = $request->query->get('id');
$entity = $this->getEntity();
$hierarchy = $entity->selectQuestionHierarchy($disciplineId);
$value = array();
if (!empty($hierarchy)) {
$value = $hierarchy;
}
$form->addElement(new Element\HTML('<legend>' . Container::get('params')->langArray['question_structure'] . '</legend>'));
$form->addElement(new AutoSubmit(Container::get('params')->langArray['autosave'] . ':', 'autosave', array('form_id' => $this->formName)));
$form->addElement(new Hierarchy(Container::get('params')->langArray['structure'] . ':', 'hierarchy', array('content' => $_SESSION[$this->formName][$request->query->get('id')]['questions'], 'groups' => array(Container::get('params')->langArray['module'], Container::get('params')->langArray['theme'], Container::get('params')->langArray['question']), 'default' => Container::get('params')->langArray['question'], 'value' => $value)));
$form = $this->addControls($form, $request);
return $form;
}
示例3: input
/**
* First step. Adding initial data.
*
* @param type $form
* @param type $request
* @param type $config
* @return type
*/
public function input($form, $request, $config)
{
$idDiscipline = $request->query->get('id');
$entity = $this->getEntity();
$questionsStr = '';
if (!empty($_SESSION[$this->formName][$request->query->get('id')]['questions'])) {
$questions = $_SESSION[$this->formName][$request->query->get('id')]['questions'];
$questionsStr = implode($questions, "\r\n");
} else {
$selection = $this->getEntity()->selectEntity($idDiscipline);
$questionsStr = '';
foreach ($selection as $row => $data) {
$questionsStr .= $data['name'] . "\r\n";
}
}
$form->addElement(new Element\HTML('<legend>Введіть запитання</legend>'));
$form->addElement(new Element\Textarea('', 'questions', array('required' => 1, 'value' => $questionsStr)));
$form = $this->addControls($form, $request);
return $form;
}
示例4: addRemoveButton
/**
* Überschrieben, damit die Unterformular Elemente nicht gruppiert werden.
* @param type $subform
*/
protected function addRemoveButton($subform)
{
$button = $this->createRemoveButton();
$button->setDecorators(array('ViewHelper'));
$subform->addElement($button);
}
示例5: createFormElements
/**
* Функция создание формы
* @param type $objForm объект формы
* @param type $elementsForm элементы в виде массива
* @return type объект формы
*/
protected function createFormElements($objForm, $elementsForm)
{
foreach ($elementsForm as $key => $value) {
// определяем тип по умолчанию
$type = !empty($value['type']) ? $value['type'] : 'text';
// массив с опциями
$params = array();
if ($type !== 'hidden') {
$params['label'] = !empty($value['label']) ? $value['label'] : die('Не оределлен атрибут label!');
}
$params['decorators'] = !empty($value['decorators']) ? $value['decorators'] : $this->elementDecorators();
if (!empty($value['multiOptions'])) {
$params['multiOptions'] = $value['multiOptions'];
}
$value['required'] = !empty($value['required']) ? $value['required'] : true;
$value['attribs'] = !empty($value['attribs']) ? $value['attribs'] : array('class' => 'form-control');
$value['filters'] = !empty($value['filters']) ? $value['filters'] : '';
$value['validators'] = !empty($value['validators']) ? $value['validators'] : '';
// присваевыем стандартные фильтры и валидаторы
if (empty($value['filters'])) {
$stringTrim = new Zend_Filter_StringTrim();
$stripTags = new Zend_Filter_StripTags();
$value['filters'] = array('stringTrim' => $stringTrim, 'stripTags' => $stripTags);
}
if (empty($value['validators'])) {
$alnum = new Zend_Validate_Alnum();
$alnum->setMessage('Только буквы и цыфры!');
$notEmpty = new Zend_Validate_NotEmpty();
$notEmpty->setMessage('Поле обязательно для заполнения', 'isEmpty');
$value['validators'] = array('alnum' => $alnum, 'notEmpty' => $notEmpty);
}
// провеки на тип если нужен новый то надо добавить по аналогии
switch ($type) {
case 'text':
$elem = new Zend_Form_Element_Text($key);
break;
case 'textarea':
$elem = new Zend_Form_Element_Textarea($key);
break;
case 'select':
$elem = new Zend_Form_Element_Select($key);
break;
case 'password':
$elem = new Zend_Form_Element_Password($key);
break;
case 'hidden':
$elem = new Zend_Form_Element_Hidden($key);
break;
case 'radio':
$elem = new Zend_Form_Element_Radio($key);
break;
}
// присваиваем атрибуты
if (!empty($value['attribs'])) {
foreach ($value['attribs'] as $k => $val) {
$params[$k] = $val;
}
}
// присваиваем опции
if (!empty($elem)) {
$elem->setOptions($params);
}
// добавляем валидаторы
if (!empty($value['validators']) && $type !== 'hidden') {
foreach ($value['validators'] as $val) {
$elem->addValidator($val);
}
}
// добавляем фильтры
if (!empty($value['filters']) && $type !== 'hidden') {
foreach ($value['filters'] as $val) {
$elem->addFilter($val);
}
}
// вот тут писец
if (!empty($value['required']) && $type !== 'hidden') {
$elem->setRequired(TRUE);
}
// добавляем элемент на форму
$objForm->addElement($elem);
}
// добавляем кнопку
$objForm->addElement('submit', 'submit', array('label' => $this->buttonLabel, 'decorators' => $this->buttonDecorators(), 'class' => 'btn btn-default'));
return $objForm;
}