本文整理汇总了PHP中Zend\Form\Element::setOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP Element::setOptions方法的具体用法?PHP Element::setOptions怎么用?PHP Element::setOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\Element
的用法示例。
在下文中一共展示了Element::setOptions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setOptions
public function setOptions($options)
{
parent::setOptions($options);
if (isset($options['form'])) {
$this->setForm($options['form']);
}
}
示例2: setOptions
/**
* Set options for a fieldset. Accepted options are:
* - use_as_base_fieldset: is this fieldset use as the base fieldset?
*
* @param array|Traversable $options
* @return Element|ElementInterface
* @throws Exception\InvalidArgumentException
*/
public function setOptions($options)
{
parent::setOptions($options);
if (isset($options['use_as_base_fieldset'])) {
$this->setUseAsBaseFieldset($options['use_as_base_fieldset']);
}
return $this;
}
示例3: setOptions
/**
* Accepted options for DateTime:
* - format: A \DateTime compatible string
*
* @param array|\Traversable $options
* @return DateTime
*/
public function setOptions($options)
{
parent::setOptions($options);
if (isset($this->options['format'])) {
$this->setFormat($this->options['format']);
}
return $this;
}
示例4: setOptions
/**
* Accepted options for Captcha:
* - captcha: a valid Zend\Captcha\AdapterInterface
*
* @param array|Traversable $options
* @return Captcha
*/
public function setOptions($options)
{
parent::setOptions($options);
if (isset($this->options['captcha'])) {
$this->setCaptcha($this->options['captcha']);
}
return $this;
}
示例5: setOptions
/**
* Accepted options for Csrf:
* - csrf_options: an array used in the Csrf
*
* @param array|\Traversable $options
* @return Csrf
*/
public function setOptions($options)
{
parent::setOptions($options);
if (isset($options['csrf_options'])) {
$this->setCsrfValidatorOptions($options['csrf_options']);
}
return $this;
}
示例6: addElement
/**
* @param Element $element
*/
public function addElement($element)
{
$options = $element->getOptions();
$options['displayGroup'] = $this->getName();
$element->setOptions($options);
$this->elements[$element->getName()] = $element;
return $this;
}
示例7: testCanCreateLabelValueAfterInput
public function testCanCreateLabelValueAfterInput()
{
$element = new Element('foo');
$element->setOptions(array('label' => 'The value for foo:'));
$this->helper->setLabelPosition('append');
$markup = $this->helper->render($element);
$this->assertContains('<label><input', $markup);
$this->assertContains('</label>', $markup);
}
示例8: setOptions
/**
* Set options for a fieldset. Accepted options are:
* - use_as_base_fieldset: is this fieldset use as the base fieldset?
*
* @param array|Traversable $options
* @return Element|ElementInterface
* @throws Exception\InvalidArgumentException
*/
public function setOptions($options)
{
parent::setOptions($options);
if (isset($options['use_as_base_fieldset'])) {
$this->setUseAsBaseFieldset($options['use_as_base_fieldset']);
}
if (isset($options['allowed_object_binding_class'])) {
$this->setAllowedObjectBindingClass($options['allowed_object_binding_class']);
}
return $this;
}
示例9: setOptions
/**
* Set options for an element. Accepted options are:
* - label: label to associate with the element
* - label_attributes: attributes to use when the label is rendered
* - value_options: list of values and labels for the select options
*
* @param array|\Traversable $options
* @return Select|ElementInterface
* @throws Exception\InvalidArgumentException
*/
public function setOptions($options)
{
parent::setOptions($options);
if (isset($this->options['value_options'])) {
$this->setValueOptions($this->options['value_options']);
}
// Alias for 'value_options'
if (isset($this->options['options'])) {
$this->setValueOptions($this->options['options']);
}
return $this;
}
示例10: setOptions
/**
* reCAPTCHA options
* - site_key: Public key (html)
* - secret_key: Private key
* - remote_ip: Check IP
*
* @param array|\Traversable $options
* @return self
* @throws Exception\InvalidArgumentException
*/
public function setOptions($options)
{
parent::setOptions($options);
if (empty($options['site_key']) || empty($options['secret_key'])) {
throw new Exception\InvalidArgumentException('The options site_key and/or secret_key were not found');
}
$this->setSiteKey($options['site_key']);
$this->setSecretKey($options['secret_key']);
if (isset($options['remote_ip'])) {
$this->setRemoteIp($options['remote_ip']);
}
return $this;
}
示例11: setOptions
/**
* Accepted options for MultiCheckbox:
* - use_hidden_element: do we render hidden element?
* - unchecked_value: value for checkbox when unchecked
* - checked_value: value for checkbox when checked
*
* @param array|\Traversable $options
* @return Checkbox
*/
public function setOptions($options)
{
parent::setOptions($options);
if (isset($options['use_hidden_element'])) {
$this->setUseHiddenElement($options['use_hidden_element']);
}
if (isset($options['unchecked_value'])) {
$this->setUncheckedValue($options['unchecked_value']);
}
if (isset($options['checked_value'])) {
$this->setCheckedValue($options['checked_value']);
}
return $this;
}
示例12: setOptions
/**
* Accepted options for DoctrineEntity:
* - object_manager: a valid Doctrine 2 ObjectManager
* - target_class: a FQCN of the target entity
* - property: the property of the entity to use as the label in the options
* - spec: a closure, QueryBuilder or Query
*
* @param array|\Traversable $options
* @return DoctrineEntity
*/
public function setOptions($options)
{
parent::setOptions($options);
if (isset($options['object_manager'])) {
$this->setObjectManager($options['object_manager']);
}
if (isset($options['target_class'])) {
$this->setTargetClass($options['target_class']);
}
if (isset($options['property'])) {
$this->setProperty($options['property']);
}
if (isset($options['spec'])) {
$this->setSpec($options['spec']);
}
return $this;
}
示例13: setOptions
/**
* Set options for an element. Accepted options are:
* - label: label to associate with the element
* - label_attributes: attributes to use when the label is rendered
* - value_options: list of values and labels for the select options
* _ empty_option: should an empty option be prepended to the options ?
*
* @param array|Traversable $options
* @return Select|ElementInterface
* @throws InvalidArgumentException
*/
public function setOptions($options)
{
parent::setOptions($options);
if (isset($this->options['value_options'])) {
$this->setValueOptions($this->options['value_options']);
}
// Alias for 'value_options'
if (isset($this->options['options'])) {
$this->setValueOptions($this->options['options']);
}
if (isset($this->options['empty_option'])) {
$this->setEmptyOption($this->options['empty_option']);
}
if (isset($this->options['disable_inarray_validator'])) {
$this->setDisableInArrayValidator($this->options['disable_inarray_validator']);
}
return $this;
}
示例14: setOptions
public function setOptions($options)
{
parent::setOptions($options);
if (isset($options['startdate'])) {
if (isset($options['startdate']['options'])) {
$this->getStartDateElement()->setOptions($options['startdate']['options']);
}
if (isset($options['startdate']['attributes'])) {
$this->getStartDateElement()->setAttributes($options['startdate']['attributes']);
}
}
if (isset($options['enddate'])) {
if (isset($options['enddate']['options'])) {
$this->getEndDateElement()->setOptions($options['enddate']['options']);
}
if (isset($options['enddate']['attributes'])) {
$this->getEndDateElement()->setAttributes($options['enddate']['attributes']);
}
}
}
示例15: getForm
public function getForm($article, $entityManager, $myEntity, $action)
{
$builder = new DoctrineAnnotationBuilder($entityManager);
$form = $builder->createForm($article);
//!!!!!! Start !!!!! Added to make the association tables work with select
foreach ($form->getElements() as $element) {
if (method_exists($element, 'getProxy')) {
$proxy = $element->getProxy();
if (method_exists($proxy, 'setObjectManager')) {
$proxy->setObjectManager($entityManager);
}
}
}
$form->setHydrator(new DoctrineHydrator($entityManager, $myEntity));
$oName = new Element('name');
$oName->setAttributes(array('type' => 'text', 'maxlength' => 255));
$oName->setOptions(array('label' => 'Название'));
$form->add($oName, array('priority' => 1000));
$oDescription = new Element('description');
$oDescription->setAttributes(array('type' => 'text', 'maxlength' => 255));
$oDescription->setOptions(array('label' => 'Описание'));
$form->add($oDescription, array('priority' => 999));
$send = new Element('send');
$send->setValue($action);
// submit
$send->setAttributes(array('type' => 'submit'));
$form->add($send);
foreach ($form->getElements() as $element) {
$element->setAttribute('id', $element->getName());
$element->setAttribute('class', 'form-control');
/*if ($element->getLabel() === null) {
$element->setOptions(array('add-on-div' => array('class' => 'col-sm-offset-2 col-sm-10'), ));
} else {
$element->setOptions(array( 'add-on-div' => array('class' => 'col-sm-10'),
'label_attributes' => array('class' => 'col-sm-2 control-label'),
));
}*/
}
return $form;
}