本文整理汇总了PHP中Zend\Form\Element::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP Element::setAttribute方法的具体用法?PHP Element::setAttribute怎么用?PHP Element::setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\Element
的用法示例。
在下文中一共展示了Element::setAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPassingElementToOpenTagWillUseIdInForAttributeWhenPresent
public function testPassingElementToOpenTagWillUseIdInForAttributeWhenPresent()
{
$element = new Element('foo');
$element->setAttribute('id', 'bar');
$markup = $this->helper->openTag($element);
$this->assertContains('for="bar"', $markup);
}
示例2: __construct
public function __construct()
{
parent::__construct('nested_fieldset');
$field = new Element('anotherField', array('label' => 'Name'));
$field->setAttribute('type', 'text');
$this->add($field);
}
示例3: testCanCreateMarkupWithoutLabel
public function testCanCreateMarkupWithoutLabel()
{
$element = new Element('foo');
$element->setAttribute('type', 'text');
$markup = $this->helper->render($element);
$this->assertRegexp('/<input name="foo" type="text"(\\s*\\/)?>/', $markup);
}
示例4: testRendersValueAttributeAsTextareaContent
public function testRendersValueAttributeAsTextareaContent()
{
$element = new Element('foo');
$element->setAttribute('value', 'Initial content');
$markup = $this->helper->render($element);
$this->assertContains('>Initial content</textarea>', $markup);
}
示例5: setAttribute
/**
* Set a single element attribute
*
* @param string $key
* @param mixed $value
* @return Element
*/
public function setAttribute($key, $value)
{
if ('captcha' == strtolower($key)) {
$this->setCaptcha($value);
return $this;
}
return parent::setAttribute($key, $value);
}
示例6: testSetUseHiddenElementAttributeDoesNotRenderHiddenInput
public function testSetUseHiddenElementAttributeDoesNotRenderHiddenInput()
{
$element = new Element('foo');
$element->setAttribute('useHiddenElement', false);
$markup = $this->helper->render($element);
$this->assertRegexp('#type="checkbox"\\s+value="1"#', $markup);
$this->assertNotRegexp('#type="hidden"\\s+name="foo"\\s+value="0"#', $markup);
}
示例7: setAttribute
/**
* Override: set a single element attribute
*
* Does not allow setting value attribute; this will always be
* retrieved from the validator.
*
* @param string $name
* @param mixed $value
* @return Csrf
*/
public function setAttribute($name, $value)
{
if ('value' == $name) {
// Do not allow setting this
return;
}
return parent::setAttribute($name, $value);
}
示例8: testRendersOnErrorAsEspected
public function testRendersOnErrorAsEspected()
{
$element = new Element('testElement');
$element->setAttribute('value', 'Initial Content');
$element->setMessages(array('testElement' => 'no valid'));
$markup = $this->helper->render($element);
$this->assertContains('error', $markup);
}
示例9: testGeneratesEmailInputTagRegardlessOfElementType
public function testGeneratesEmailInputTagRegardlessOfElementType()
{
$element = new Element('foo');
$element->setAttribute('type', 'radio');
$markup = $this->helper->render($element);
$this->assertContains('<input ', $markup);
$this->assertContains('type="email"', $markup);
}
示例10: testOpenTagOnlyAllowsValidButtonTypes
/**
* @dataProvider inputTypes
*/
public function testOpenTagOnlyAllowsValidButtonTypes($type, $assertion)
{
$element = new Element('foo');
$element->setAttribute('type', $type);
$markup = $this->helper->openTag($element);
$expected = sprintf('type="%s"', $type);
$this->{$assertion}($expected, $markup);
}
示例11: __construct
public function __construct()
{
parent::__construct('basic_fieldset');
$field = new Element('field', array('label' => 'Name'));
$field->setAttribute('type', 'text');
$this->add($field);
$nestedFieldset = new NestedFieldset();
$this->add($nestedFieldset);
}
示例12: testInvokeProxiesToRender
public function testInvokeProxiesToRender()
{
$element = new Element('foo');
$element->setAttribute('src', 'foo.png');
$markup = $this->helper->__invoke($element);
$this->assertContains('<input', $markup);
$this->assertContains('name="foo"', $markup);
$this->assertContains('type="image"', $markup);
$this->assertContains('src="foo.png"', $markup);
}
示例13: __construct
public function __construct()
{
parent::__construct('test_form');
$this->setAttribute('method', 'post')->setHydrator(new ClassMethodsHydrator());
$field1 = new Element('name', array('label' => 'Name'));
$field1->setAttribute('type', 'text');
$this->add($field1);
$field2 = new Element('email', array('label' => 'Email'));
$field2->setAttribute('type', 'text');
$this->add($field2);
$this->add(array('name' => 'csrf', 'type' => 'Zend\\Form\\Element\\Csrf', 'attributes' => array()));
$this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit')));
}
示例14: __construct
public function __construct($name = null, $options = array())
{
parent::__construct("page", $options);
$this->setAttribute("method", "post");
$this->setAttribute("id", "pageform");
$this->add(array("name" => "id", "attributes" => array("type" => "hidden", "value" => "0")));
$this->add(array("name" => "article", "attributes" => array("type" => "textarea"), "options" => array("label" => "Description")));
$title = new Element("title");
$title->setAttribute("type", "text");
$title->setLabel("Title");
$this->add($title);
$this->add(array("name" => "date", "attributes" => array("type" => "text"), "options" => array("label" => "Publication Date")));
$this->add(array("name" => "submit", "type" => "submit", "attributes" => array("value" => "Отправить", "id" => "submitbutton", "class" => "btn")));
}
示例15: __invoke
/**
* Outputs message depending on flag
*
* @return string
*/
public function __invoke(Element $element)
{
$element->setLabelAttributes(array('class' => 'control-label'));
$element->setAttribute('data-placement', 'bottom')->setAttribute('data-content', $element->getOption('description'));
if (!$element->getLabel()) {
$element->setLabel('öö');
}
$output = '<div class="control-group">';
$output .= $this->getView()->formLabel($element);
$output .= '<div class="controls">';
$output .= $this->getView()->formElement($element);
if ($element->getOption('description')) {
$output .= '<div class="description">' . $element->getOption('description') . '</div>';
}
if ($element->getMessages()) {
$output .= '<div class="alert alert-error">' . $this->getView()->formElementErrors($element) . '</div>';
}
$output .= '</div>';
$output .= '</div>';
return $output;
}