本文整理匯總了PHP中Zend\Form\Element\Button::setAttribute方法的典型用法代碼示例。如果您正苦於以下問題:PHP Button::setAttribute方法的具體用法?PHP Button::setAttribute怎麽用?PHP Button::setAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\Form\Element\Button
的用法示例。
在下文中一共展示了Button::setAttribute方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: init
public function init()
{
$fileupload = new Element\File('files');
$fileupload->setLabel("files");
$fileupload->setAttribute('multiple', 'multiple');
$this->add($fileupload);
$button = new Element\Button('start');
$button->setAttribute("type", 'submit');
$button->setValue("Start upload")->setLabel("Start upload");
$this->add($button);
$button = new Element\Button('cancel');
$button->setAttribute("type", 'reset');
$button->setValue("Cancel upload")->setLabel("Cancel upload");
$this->add($button);
$button = new Element\Button('delete');
$button->setAttribute("type", 'button');
$button->setValue("Delete")->setLabel("Delete");
$this->add($button);
$checkbox = new Element\Checkbox('toggle');
$checkbox->setValue("Toggle")->setLabel("Toggle");
$checkbox->setAttribute("required", "");
$this->add($checkbox);
}
示例2: getFilterForm
/**
* @throws RuntimeException
* @return Form
*/
public function getFilterForm()
{
$filters = $this->entity->getOptions()->getFilter();
if ($filters) {
if (is_string($filters)) {
$form = $this->serviceLocator->get($filters);
} elseif (is_array($filters)) {
$simple = true;
foreach ($filters as $filter) {
$simple = $simple && is_string($filter);
}
if ($simple) {
$form = new Form();
$form->setAttribute('method', 'GET');
foreach ($filters as $filter) {
$label = str_replace('_', ' ', $filter);
$form->add(new Text($filter, ['label' => $label]));
}
$submit = new Button('submit', ['label' => 'Filter']);
$submit->setAttribute('type', 'submit');
$form->add($submit);
} else {
$factory = new Factory();
$form = $factory->createForm($filters);
}
} else {
throw new RuntimeException('Unknown type of filter');
}
return $form;
}
return new Form();
}