本文整理汇总了PHP中Zend\Form\Fieldset::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Fieldset::add方法的具体用法?PHP Fieldset::add怎么用?PHP Fieldset::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\Fieldset
的用法示例。
在下文中一共展示了Fieldset::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($name = 'register-form', CaptchaOptions $options, $role = 'recruiter')
{
parent::__construct($name, []);
$this->setAttribute('data-handle-by', 'native');
$this->setAttribute('class', 'form-horizontal');
$fieldset = new Fieldset('register');
$fieldset->setOptions(array('renderFieldset' => true));
$fieldset->add(array('type' => 'text', 'name' => 'name', 'options' => array('label' => 'Name')));
$fieldset->add(array('type' => 'email', 'name' => 'email', 'options' => array('label' => 'Email'), 'attributes' => ['required' => true]));
$fieldset->add(array('name' => 'role', 'type' => 'hidden', 'attributes' => array('value' => $role)));
$this->add($fieldset);
$mode = $options->getMode();
if (in_array($mode, [CaptchaOptions::RE_CAPTCHA, CaptchaOptions::IMAGE])) {
if ($mode == CaptchaOptions::IMAGE) {
$captcha = new Image($options->getImage());
} elseif ($mode == CaptchaOptions::RE_CAPTCHA) {
$captcha = new ReCaptcha($options->getReCaptcha());
}
if (!empty($captcha)) {
$this->add(array('name' => 'captcha', 'options' => array('label' => 'Are you human?', 'captcha' => $captcha), 'type' => 'Zend\\Form\\Element\\Captcha'));
}
}
$buttons = new ButtonsFieldset('buttons');
$buttons->add(array('type' => 'submit', 'name' => 'button', 'attributes' => array('type' => 'submit', 'value' => 'Register', 'class' => 'btn btn-primary')));
$this->add(array('name' => 'csrf', 'type' => 'csrf', 'options' => array('csrf_options' => array('salt' => str_replace('\\', '_', __CLASS__), 'timeout' => 3600))));
$this->add($buttons);
}
示例2: __construct
public function __construct($name = 'register-form', $options = array())
{
parent::__construct($name, $options);
$this->setAttribute('data-handle-by', 'native');
$this->setAttribute('class', 'form-horizontal');
$fieldset = new Fieldset('register');
$fieldset->setOptions(array('renderFieldset' => true));
$fieldset->add(array('type' => 'text', 'name' => 'name', 'options' => array('label' => 'Name')));
$fieldset->add(array('type' => 'email', 'name' => 'email', 'options' => array('label' => 'Email')));
$fieldset->add(array('name' => 'role', 'type' => 'hidden', 'attributes' => array('value' => User::ROLE_RECRUITER)));
$this->add($fieldset);
if (($captchaOptions = $this->getOption('captcha')) && !empty($captchaOptions['use'])) {
if ($captchaOptions['use'] === 'image' && !empty($captchaOptions['image'])) {
$captcha = new Image($captchaOptions['image']);
} elseif ($captchaOptions['use'] === 'reCaptcha' && !empty($captchaOptions['reCaptcha'])) {
$captcha = new ReCaptcha($captchaOptions['reCaptcha']);
}
if (!empty($captcha)) {
$this->add(array('name' => 'captcha', 'options' => array('label' => 'Are you human?', 'captcha' => $captcha), 'type' => 'Zend\\Form\\Element\\Captcha'));
}
}
$buttons = new ButtonsFieldset('buttons');
$buttons->add(array('type' => 'submit', 'name' => 'button', 'attributes' => array('type' => 'submit', 'value' => 'Register', 'class' => 'btn btn-primary')));
$this->add(array('name' => 'csrf', 'type' => 'csrf', 'options' => array('csrf_options' => array('salt' => str_replace('\\', '_', __CLASS__), 'timeout' => 3600))));
$this->add($buttons);
}
示例3: addButtons
public function addButtons()
{
$fieldSet = new Fieldset('buttons');
$fieldSet->setAttributes(array('class' => 'dots-form-buttons'));
$fieldSet->add(array('name' => 'cancel', 'options' => array('label' => 'Cancel'), 'attributes' => array('type' => 'button', 'class' => 'btn', 'data-action' => 'link_cancel')));
$fieldSet->add(array('name' => 'save', 'options' => array('label' => 'Save'), 'attributes' => array('type' => 'button', 'class' => 'btn btn-primary', 'data-action' => 'link_save')));
$this->add($fieldSet);
}
示例4: prepareConfig
/**
* Prepare elements for configuration
*
* @return void
*/
public function prepareConfig()
{
$options = $this->getModel()->getConfig();
$fieldset = new Fieldset('config');
$language = new Element\Select('language');
$language->setLabel('Language')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValueOptions($this->getModel()->getLanguages())->setValue($options['language']);
$fieldset->add($language);
$ga = new Element\Text('data_ga_property_id');
$ga->setLabel('Google Analytics property ID')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValue($options['data_ga_property_id']);
$fieldset->add($ga);
$showOnDashboard = new Element\Checkbox('show_stats');
$showOnDashboard->setLabel('Show stats on dashboard')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('id', 'show_stats')->setAttribute('class', 'input-checkbox')->setValue($options['show_stats']);
$fieldset->add($showOnDashboard);
$profileId = new Element\Text('profile_id');
$profileId->setLabel('AddThis Profile ID')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValue($options['profile_id']);
$fieldset->add($profileId);
$username = new Element\Text('username');
$username->setLabel('AddThis Username')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValue($options['username']);
$fieldset->add($username);
$password = new Element\Password('password');
$password->setLabel('AddThis Password')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValue($options['password']);
$fieldset->add($password);
$dataTrackClickback = new Element\Checkbox('data_track_clickback');
$dataTrackClickback->setLabel('Track clickback')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('id', 'data_track_clickback')->setAttribute('class', 'input-checkbox')->setValue($options['data_track_clickback']);
$fieldset->add($dataTrackClickback);
$dataTrackAddressbar = new Element\Checkbox('data_track_addressbar');
$dataTrackAddressbar->setLabel('Track adressbar')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('id', 'data_track_addressbar')->setAttribute('class', 'input-checkbox')->setValue($options['data_track_addressbar']);
$fieldset->add($dataTrackAddressbar);
$jsonConfig = new Element\Textarea('config_json');
$jsonConfig->setLabel('Json config')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValue($options['config_json']);
$fieldset->add($jsonConfig);
$this->add($fieldset);
$this->getInputFilter()->add(array('type' => 'Zend\\InputFilter\\InputFilter', 'language' => array('name' => 'language', 'required' => true), 'data_ga_property_id' => array('name' => 'data_ga_property_id', 'required' => false), 'profile_id' => array('name' => 'profile_id', 'required' => false, 'validators' => array(array('name' => 'Callback', 'options' => array('messages' => array(\Zend\Validator\Callback::INVALID_VALUE => 'Can not connect to addthis api'), 'callback' => function ($value, $context = array()) {
if (empty($context['username']) or empty($context['password'])) {
return false;
}
return true;
})))), 'show_stats' => array('name' => 'show_stats', 'required' => false), 'password' => array('name' => 'password', 'required' => false, 'validators' => array(array('name' => 'Callback', 'options' => array('messages' => array(\Zend\Validator\Callback::INVALID_VALUE => 'Can not connect to addthis api'), 'callback' => function ($value, $context = array()) {
if (empty($context['username']) or empty($context['profile_id'])) {
return false;
}
return true;
})))), 'username' => array('name' => 'username', 'required' => false, 'validators' => array(array('name' => 'Callback', 'options' => array('messages' => array(\Zend\Validator\Callback::INVALID_VALUE => 'Can not connect to addthis api'), 'callback' => function ($value, $context = array()) {
$client = new Client('https://api.addthis.com/analytics/1.0/pub/shares.json', array('sslverifypeer' => false));
$client->setParameterGet(array('username' => $context['username'], 'password' => $context['password'], 'pubid' => $context['profile_id']));
try {
$response = $client->send();
if ($response->isSuccess() == 200) {
return true;
}
} catch (\Exception $e) {
//don't care
}
return false;
})))), 'data_track_clickback' => array('name' => 'data_track_clickback', 'required' => false), 'data_track_addressbar' => array('name' => 'data_track_addressbar', 'required' => false), 'json_config' => array('name' => 'json_config', 'required' => false)), 'config');
}
示例5: createService
public function createService(ServiceLocatorInterface $serviceLocator)
{
$form = new Form();
$form->setName('login-form');
$form->add(array('type' => 'hidden', 'name' => 'ref'));
$fieldset = new Fieldset();
$fieldset->add(array('name' => 'login', 'options' => array('label' => 'Login name', 'description' => 'Provide your login key (e.g. email adress)')));
$fieldset->add(array('type' => 'password', 'name' => 'credential', 'options' => array('label' => 'Password')));
$form->add($fieldset);
$form->add($this->forms->get('DefaultButtonsFieldset'));
}
示例6: __construct
public function __construct($name = 'login-form', $options = array())
{
parent::__construct($name, $options);
$this->setAttribute('data-handle-by', 'native');
$this->setAttribute('class', 'form-inline');
$fieldset = new Fieldset('credentials');
$fieldset->setOptions(array('renderFieldset' => true));
$fieldset->add(array('name' => 'login', 'options' => array('id' => 'login', 'label' => 'Login name')));
$fieldset->add(array('type' => 'password', 'name' => 'credential', 'options' => array('id' => 'credential', 'label' => 'Password')));
$this->add($fieldset);
$buttons = new \Core\Form\ButtonsFieldset('buttons');
$buttons->add(array('type' => 'submit', 'name' => 'button', 'attributes' => array('id' => 'submit', 'type' => 'submit', 'value' => 'login', 'class' => 'btn btn-primary')));
$this->add($buttons);
}
示例7: init
public function init()
{
$this->setName('login-form');
$this->setAttribute('data-handle-by', 'native');
$fieldset = new Fieldset('credentials');
//$fieldset->setLabel('Enter your credentials');
$fieldset->setOptions(array('renderFieldset' => true));
$fieldset->add(array('name' => 'login', 'options' => array('label' => 'Login name')));
$fieldset->add(array('type' => 'password', 'name' => 'credential', 'options' => array('label' => 'Password')));
$this->add($fieldset);
$buttons = new \Core\Form\ButtonsFieldset('buttons');
$buttons->add(array('type' => 'submit', 'name' => 'button', 'attributes' => array('id' => 'submit', 'type' => 'submit', 'value' => 'login', 'class' => 'btn btn-primary')));
$this->add($buttons);
}
示例8: __construct
/**
* Class constructor
*/
public function __construct()
{
parent::__construct();
$this->setAttribute('method', 'get');
$this->setAttribute('class', 'form-horizontal');
for ($i = 0; $i <= 2; $i++) {
$filter = new Fieldset('selection' . $i);
$filter->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'in', 'options' => ['value_options' => $this->inOptions], 'attributes' => ['label' => 'search']]);
$filter->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'selection', 'attributes' => ['label' => 'search', 'class' => 'form-control', 'id' => "search", 'placeholder' => _("txt-site-search")]]);
$this->add($filter);
}
$this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'cancel', 'attributes' => ['class' => "btn btn-danger", 'value' => _("txt-cancel")]]);
$this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-submit")]]);
}
示例9: __construct
/**
* @param GeneralService $mailingService
*/
public function __construct(GeneralService $mailingService)
{
parent::__construct();
$this->setAttribute('method', 'get');
$this->setAttribute('action', '');
$filterFieldset = new Fieldset('filter');
$filterFieldset->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'search', 'attributes' => ['class' => 'form-control', 'placeholder' => _('txt-search')]]);
$yesNo = [1 => 'YES', 0 => 'NO'];
$filterFieldset->add(['type' => 'Zend\\Form\\Element\\Radio', 'name' => 'eu', 'options' => ['value_options' => $yesNo, 'inline' => true], 'attributes' => ['label' => _("txt-eu")]]);
$filterFieldset->add(['type' => 'Zend\\Form\\Element\\Radio', 'name' => 'eureka', 'options' => ['value_options' => $yesNo, 'inline' => true], 'attributes' => ['label' => _("txt-eureka")]]);
$filterFieldset->add(['type' => 'Zend\\Form\\Element\\Radio', 'name' => 'itac', 'options' => ['value_options' => $yesNo, 'inline' => true], 'attributes' => ['label' => _("txt-itac-form-label")]]);
$this->add($filterFieldset);
$this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['id' => 'submit', 'class' => 'btn btn-primary', 'value' => _('txt-filter')]]);
$this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'clear', 'attributes' => ['id' => 'cancel', 'class' => 'btn btn-warning', 'value' => _('txt-cancel')]]);
}
示例10: testCanRenderFieldsets
/**
* @outputBuffering disabled
*/
public function testCanRenderFieldsets()
{
$this->expectOutputRegex('/<form(.*)<fieldset(.*)<\\/fieldset>(.*)<fieldset(.*)<\\/fieldset>(.*)<\\/form>/');
$form = new NetsensiaForm();
$form->addHidden('test1', 'testvalue');
$hidden = new Element\Hidden('asdasd');
$hidden->setValue('123');
$form->add($hidden);
$element1 = new Text('testelement1');
$element1->setLabel('Test Element');
$element1->setAttribute('icon', 'pencil');
$element2 = new Text('testelement2');
$element2->setLabel('Test Element 2');
$element2->setAttribute('icon', 'pencil');
$fieldset1 = new Fieldset('testfieldset1');
$fieldset1->add($element1);
$fieldset2 = new Fieldset('testfieldset2');
$fieldset2->add($element2);
$form->add($fieldset1);
$form->add($fieldset2);
$helpers = new HelperPluginManager();
$helpers->setService('formElement', new FormElement());
$view = new PhpRenderer();
$view->setHelperPluginManager($helpers);
$viewHelper = new BootstrapForm();
$viewHelper->setView($view);
$viewHelper($form, 'testform', '/');
}
示例11: add
/**
* @see \Zend\Form\Form::add
*
* @param array|\Traversable|\Zend\Form\ElementInterface $elementOrFieldset
* @param array $flags
* @throws \Exception
* @return $this
*
* @author Alaa Al-Maliki <aal@amp.co>
*/
public function add($elementOrFieldset, array $flags = [])
{
if (array_key_exists('renderer', $elementOrFieldset)) {
$renderer = isset($elementOrFieldset['renderer']) ? $elementOrFieldset['renderer'] : '';
if (is_string($renderer) && !class_exists($renderer)) {
throw new \Exception("Class: " . $renderer . " is not defined.");
}
if (!is_object($renderer)) {
$renderer = '\\' . $renderer;
$rendererClass = new $renderer();
} else {
$rendererClass = $renderer;
}
if ($rendererClass instanceof Select) {
$elementOrFieldset['type'] = get_class($rendererClass);
} else {
$elementOrFieldset['type'] = 'Zend\\Form\\Element\\Select';
}
if (array_key_exists('renderer_label', $elementOrFieldset)) {
$label = isset($elementOrFieldset['renderer_label']) ? $elementOrFieldset['renderer_label'] : '';
if ($label) {
$elementOrFieldset['options']['label'] = $label;
}
}
$options = method_exists($rendererClass, 'toOptionArray') ? $rendererClass->toOptionArray() : array();
if (!is_array($options)) {
$options = array();
}
$elementOrFieldset['options']['value_options'] = $options;
}
return parent::add($elementOrFieldset, $flags);
}
示例12: populateFieldset
public function populateFieldset()
{
$this->fieldset->add(new Element('foo'));
$this->fieldset->add(new Element('bar'));
$this->fieldset->add(new Element('baz'));
$subFieldset = new Fieldset('foobar');
$subFieldset->add(new Element('foo'));
$subFieldset->add(new Element('bar'));
$subFieldset->add(new Element('baz'));
$this->fieldset->add($subFieldset);
$subFieldset = new Fieldset('barbaz');
$subFieldset->add(new Element('foo'));
$subFieldset->add(new Element('bar'));
$subFieldset->add(new Element('baz'));
$this->fieldset->add($subFieldset);
}
示例13: load
/**
* Load upload prevalue editor
*
* @return string
*/
public function load()
{
$parameters = $this->getConfig();
$elements = array();
$optionsValues = !empty($parameters['options']) ? $parameters['options'] : array();
$fieldset = new Fieldset('Available options');
$element = new Element\MultiCheckbox('options');
$element->setAttribute('selected', $optionsValues);
$element->setAttribute('class', 'input-checkbox');
$element->setValueOptions(array(array('value' => 'maxNumberOfFiles', 'label' => 'Is multiple', 'selected' => empty($optionsValues['maxNumberOfFiles']) ? false : true)));
$fieldset->add($element);
$elements[] = $fieldset;
$element = new Element\MultiCheckbox('mime_list');
$mimeList = array('image/gif', 'image/jpeg', 'image/png', 'image/tiff', 'image/svg+xml', 'text/css', 'text/csv', 'text/html', 'text/javascript', 'text/plain', 'text/xml', 'video/mpeg', 'video/mp4', 'video/quicktime', 'video/x-ms-wmv', 'video/x-msvideo', 'video/x-flv', 'audio/mpeg', 'audio/x-ms-wma', 'audio/vnd.rn-realaudio', 'audio/x-wav');
$options = array();
foreach ($mimeList as $mime) {
$options[] = array('value' => $mime, 'label' => $mime, 'selected' => !in_array($mime, empty($parameters['mime_list']) ? array() : $parameters['mime_list']) ? false : true);
}
$element->setValueOptions($options);
$element->setAttribute('class', 'input-checkbox');
$fieldset = new Fieldset('Mime list');
$fieldset->add($element);
$elements[] = $fieldset;
return $this->addPath(__DIR__)->render('upload-prevalue.phtml', array('elements' => $elements));
}
示例14: addElements
public function addElements()
{
$fieldset = new Fieldset('fieldset');
// File Input
$file = new Element\File('file');
$file->setLabel('Multi-File Input 1')->setAttributes(array('multiple' => true));
$fieldset->add($file);
// Text Input
$text = new Element\Text('text');
$text->setLabel('Text Entry');
$fieldset->add($text);
$this->add($fieldset);
// File Input 2
$file2 = new Element\File('file2');
$file2->setLabel('Multi-File Input 2')->setAttributes(array('multiple' => true));
$this->add($file2);
}
示例15: __construct
public function __construct()
{
$inputFilterForm = new InputFilter();
parent::__construct('form');
$this->setInputFilter($inputFilterForm);
$name = new Element('name');
$name->setLabel('Your name');
$name->setAttributes(array('type' => 'text'));
$inputFilterForm->add(array('name' => 'name', 'required' => true, 'validators' => array(array('name' => 'Zend\\Validator\\NotEmpty'))));
$email = new Element('email');
$email->setLabel('Your email');
$email->setAttributes(array('type' => 'text'));
$inputFilterForm->add(array('name' => 'email', 'required' => true, 'validators' => array(array('name' => 'Zend\\Validator\\EmailAddress'))));
$photo = new Element('photo');
$photo->setLabel('Your photo');
$photo->setAttributes(array('type' => 'file'));
$inputFilterFieldset = new InputFilter();
// ---------- FieldsetsElements ----------
$username = new Element('username');
$username->setLabel('Your username');
$username->setAttributes(array('type' => 'text'));
$inputFilterFieldset->add(array('name' => 'username', 'required' => true, 'validators' => array(array('name' => 'Zend\\Validator\\NotEmpty'))));
$inputFilterFieldset->add(array('name' => 'password', 'required' => true, 'validators' => array(array('name' => 'Zend\\Validator\\NotEmpty'))));
$password = new Element('password');
$password->setLabel('Your password');
$password->setAttributes(array('type' => 'password'));
$vpassword = new Element('verify_password');
$vpassword->setLabel('Verify your password');
$vpassword->setAttributes(array('type' => 'password'));
// ---------- FieldsetsElements ----------
$fieldsetCredential = new Fieldset('id_credential');
$fieldsetCredential->add($username);
$fieldsetCredential->add($password);
$fieldsetCredential->add($vpassword);
$inputFilterForm->add($inputFilterFieldset, 'id_credential');
$submit = new Element('submit');
$submit->setAttributes(array('value' => 'ENVIAR', 'type' => 'submit'));
// ---------- Formulario ----------
$this->setHydrator(new \Zend\Stdlib\Hydrator\ClassMethods());
$this->add($name);
$this->add($email);
$this->add($photo);
$this->add($fieldsetCredential);
$this->add($submit);
}