本文整理汇总了PHP中Zend\Form\Form::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::setAttribute方法的具体用法?PHP Form::setAttribute怎么用?PHP Form::setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\Form
的用法示例。
在下文中一共展示了Form::setAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getForm
public function getForm(array $urlType)
{
if ($this->form) {
return $this->form;
}
$form = new Form();
$form->setAttribute('class', 'form-horizontal');
$form->setAttribute('role', 'form');
$form->add(array('name' => 'menuId', 'type' => 'Hidden'));
$form->add(array('name' => 'title', 'type' => 'text', 'options' => array('label' => 'Title'), 'attributes' => array('class' => 'form-control')));
$form->add(array('name' => 'description', 'type' => 'Textarea', 'options' => array('label' => 'Description'), 'attributes' => array('class' => 'form-control', 'placeholder' => 'description')));
$form->add(array('name' => 'icon', 'type' => 'text', 'options' => array('label' => 'Icon'), 'attributes' => array('class' => 'form-control', 'placeholder' => 'Icon Class')));
$form->add(array('name' => 'url', 'type' => 'text', 'options' => array('label' => 'Url'), 'attributes' => array('class' => 'form-control', 'placeholder' => 'Url')));
$url_type = new Select('url_type');
$url_type->setLabel('Type')->setAttribute('class', 'form-control')->setValueOptions($urlType)->setEmptyOption('-- Choose URL Type --');
$form->add($url_type);
$hasDivider = new Checkbox('hasDivider');
$hasDivider->setLabel('Has divider?');
$form->add($hasDivider);
$form->add(array('name' => 'parentId', 'type' => 'hidden'));
$form->add(array('name' => 'priority', 'type' => 'number', 'options' => array('label' => 'Priority'), 'attributes' => array('class' => 'form-control')));
$form->setInputFilter($this->getInputFilter());
$this->form = $form;
return $this->form;
}
示例2: getForm
public function getForm(array $default_status)
{
if (!$this->form) {
$hidId = new Element\Hidden();
$hidId->setName('userId');
$txtName = new Element\Text();
$txtName->setLabel('User Name')->setName("userName")->setAttribute('class', 'form-control');
$password = new Element\Password();
$password->setLabel('Password')->setName('password')->setAttribute('class', 'form-control');
$confirmPassword = new Element\Password();
$confirmPassword->setName('confirmPassword')->setLabel('Retype Password')->setAttribute('class', 'form-control');
$selectRole = new Element\Hidden('userRole');
$description = new Element\Textarea();
$description->setName('description')->setLabel('Description')->setAttribute('class', 'form-control');
$status = new Element\Select();
$status->setName('status')->setLabel('Status')->setAttribute('class', 'form-control')->setValueOptions($default_status);
$image = new Element\File();
$image->setName('image')->setLabel('Profile image');
$form = new Form();
$form->setAttribute('class', 'form-horizontal');
$form->setAttribute('enctype', 'multipart/form-data');
$form->add($hidId);
$form->add($txtName);
$form->add($password);
$form->add($confirmPassword);
$form->add($selectRole);
$form->add($description);
$form->add($status);
$form->add($image);
$this->form = $form;
}
return $this->form;
}
示例3: __invoke
/**
* Outputs message depending on flag
*
* @return string
*/
public function __invoke(Form $form, $url, $class = 'form-horizontal')
{
$form->setAttribute('action', $url);
$form->setAttribute('class', $class);
$form->prepare();
$output = $this->getView()->form()->openTag($form);
$submitElements = array();
foreach ($form as $element) {
if ($element instanceof Submit) {
$submitElements[] = $element;
} elseif ($element instanceof Csrf || $element instanceof Hidden) {
$output .= $this->getView()->formElement($element);
} else {
$element->setLabelAttributes(array('class' => 'control-label'));
$output .= '<div class="control-group">';
$output .= $this->getView()->formLabel($element);
$output .= '<div class="controls">';
$output .= $this->getView()->formElement($element);
$output .= $this->getView()->formElementErrors($element);
$output .= '</div>';
$output .= '</div>';
}
}
$output .= '<div class="form-actions">';
foreach ($submitElements as $element) {
$output .= $this->getView()->formElement($element) . ' ';
}
$output .= '</div>';
$output .= $this->getView()->form()->closeTag();
return $output;
}
示例4: __invoke
public function __invoke(Form $form, $action)
{
$form->setAttribute('method', 'post');
$form->setAttribute('action', $action);
$form->prepare();
$view = $this->getView();
$html = '';
$html .= $view->form()->openTag($form);
$html .= '<table class="default-table">';
$formElements = $form->getElements();
foreach ($formElements as $formElement) {
if ($formElement instanceof Checkbox) {
$html .= $view->formRowCheckbox($form, $formElement);
} else {
if ($formElement instanceof Submit) {
$html .= $view->formRowSubmit($form, $formElement);
} else {
$html .= $view->formRowDefault($form, $formElement);
}
}
}
$html .= '</table>';
$html .= $view->form()->closeTag();
return $html;
}
示例5: getForm
public function getForm(array $currencies, array $companies, array $contacts, array $statusList)
{
if (!$this->form) {
$hidId = new Element\Hidden();
$hidId->setName('proposalId');
$txtCompanyId = new Element\Select();
$txtCompanyId->setLabel('Company Name')->setName("companyId")->setAttribute('class', 'form-control')->setEmptyOption("--Choose Company--")->setValueOptions($companies);
$txtContactId = new Element\Select();
$txtContactId->setLabel('Contact Name')->setName('contactId')->setAttribute('class', 'form-control')->setEmptyOption("--Choose Contact--")->setValueOptions($contacts);
$txtCode = new Element\Text();
$txtCode->setLabel('Code')->setName('code')->setAttribute('class', 'form-control');
$txtName = new Element\Text();
$txtName->setLabel('Name')->setName('name')->setAttribute('class', 'form-control');
$txtAmount = new Element\Number();
$txtAmount->setName("amount")->setLabel('Amount')->setAttribute('class', 'form-control')->setAttributes(array('min' => '100', 'max' => '99999999999', 'step' => '100'));
$selectCurrency = new Element\Select();
$selectCurrency->setName('currencyId')->setLabel('Currency')->setAttribute('class', 'form-control')->setValueOptions($currencies);
$txtProposalDate = new Element\Date('proposalDate');
$txtProposalDate->setLabel('Date')->setAttributes(array('class' => 'form-control', 'allowPastDates' => true, 'momentConfig' => array('format' => 'YYYY-MM-DD')));
$txtProposalFile = new Element\File();
$txtProposalFile->setName('proposalFile')->setLabel('Upload file');
$txtNodes = new Element\Textarea();
$txtNodes->setLabel('Notes')->setName('notes')->setAttribute('class', 'form-control');
$txtProposalBy = new Element\Text();
$txtProposalBy->setName('proposalBy')->setLabel('Proposal By')->setAttribute('class', 'form-control');
$txtGroupCode = new Element\Text();
$txtGroupCode->setLabel('Group Code')->setName('group_code')->setAttribute('class', 'form-control');
$txtStatus = new Element\Select();
$txtStatus->setName('status')->setLabel('Status')->setAttribute('class', 'form-control')->setValueOptions($statusList);
$form = new Form();
$form->setAttribute('class', 'form-horizontal');
$form->setAttribute('enctype', 'multipart/form-data');
$form->add($hidId);
$form->add($txtCompanyId);
$form->add($txtContactId);
$form->add($txtCode);
$form->add($txtName);
$form->add($txtAmount);
$form->add($selectCurrency);
$form->add($txtProposalDate);
$form->add($txtProposalFile);
$form->add($txtNodes);
$form->add($txtProposalBy);
$form->add($txtGroupCode);
$form->add($txtStatus);
$this->form = $form;
}
return $this->form;
}
示例6: getForm
public function getForm(array $defaultStatus)
{
if (!$this->form) {
$currencyId = new Element\Hidden();
$currencyId->setName('currencyId');
$name = new Element\Text();
$name->setLabel('Name')->setName("name")->setAttribute('class', 'form-control');
$code = new Element\Text();
$code->setLabel('Code')->setName("code")->setAttribute('class', 'form-control');
$rate = new Element\Text();
$rate->setLabel('Rate')->setName("rate")->setAttributes(array('class' => 'form-control'));
$status = new Element\Select();
$status->setName('status')->setLabel('Status')->setAttribute('class', 'form-control')->setValueOptions($defaultStatus);
$changedRate = new Element\Checkbox();
$changedRate->setName('changedRate')->setLabel('Auto renew?')->setAttribute('class', 'form-control');
$form = new Form();
$form->setAttribute('class', 'form-horizontal');
$form->add($currencyId);
$form->add($code);
$form->add($name);
$form->add($rate);
$form->add($status);
$form->add($changedRate);
$this->form = $form;
}
return $this->form;
}
示例7: getForm
public function getForm(array $defaultStatus, array $currencyList)
{
if (!$this->form) {
$positionId = new Element\Hidden();
$positionId->setName('positionId');
$name = new Element\Text();
$name->setLabel('Name')->setName("name")->setAttribute('class', 'form-control');
$minSalary = new Element\Text();
$minSalary->setLabel('MinSalary')->setName("min_Salary")->setAttribute('class', 'form-control');
$maxSalary = new Element\Text();
$maxSalary->setLabel('MaxSalary')->setName("max_Salary")->setAttribute('class', 'form-control');
$currency = new Element\Select();
$currency->setName('currencyId')->setLabel('Currency Type')->setAttribute('class', 'form-control')->setEmptyOption('-- Choose Currency --')->setValueOptions($currencyList);
$status = new Element\Select();
$status->setName('status')->setLabel('Status')->setAttribute('class', 'form-control')->setValueOptions($defaultStatus);
$form = new Form();
$form->setAttribute('class', 'form-horizontal');
$form->add($positionId);
$form->add($name);
$form->add($currency);
$form->add($minSalary);
$form->add($maxSalary);
$form->add($status);
$this->form = $form;
}
return $this->form;
}
示例8: getForm
/**
* {@inheritDoc}
*/
public function getForm()
{
$currentStep = $this->getCurrentStep();
if (!$currentStep) {
return;
}
if (null === $this->form) {
$this->form = $this->formFactory->create();
$this->form->setAttribute('action', sprintf('?%s=%s', $this->getOptions()->getTokenParamName(), $this->getUniqueId()));
if (!$this->getSteps()->getPrevious($currentStep)) {
$this->form->remove('previous');
}
if (!$this->getSteps()->getNext($currentStep)) {
$this->form->remove('next');
} else {
$this->form->remove('valid');
}
}
$stepForm = $currentStep->getForm();
if ($stepForm instanceof Form) {
if ($this->form->has(self::STEP_FORM_NAME)) {
$this->form->remove(self::STEP_FORM_NAME);
}
$stepForm->setName(self::STEP_FORM_NAME);
$stepForm->populateValues($currentStep->getData());
$this->form->add($stepForm);
}
return $this->form;
}
示例9: __construct
public function __construct(AuthenticationService $authService)
{
parent::__construct('login');
$this->filter = new InputFilter();
$email = new Element\Email('email');
$email->setAttribute('required', true);
$email->setAttribute('placeholder', 'Email Address');
$this->add($email);
$emailFilter = new Input('email');
$emailFilter->setRequired(true);
$this->filter->add($emailFilter);
$password = new Element\Password('password');
$password->setAttribute('required', true);
$password->setAttribute('placeholder', 'Password');
$this->add($password);
$passwordFilter = new Input('password');
$passwordFilter->setRequired(true);
$passwordFilter->getValidatorChain()->attach(new AuthValidator\Authentication(array('message' => 'Invalid email address or password', 'service' => $authService, 'adapter' => $authService->getAdapter(), 'identity' => 'email', 'credential' => 'password')));
$this->filter->add($passwordFilter);
$buttons = new Form('buttons');
$buttons->setOption('twb-layout', 'inline');
$buttons->setAttribute('class', 'form-group');
$submit = new Element\Submit('submit');
$submit->setAttribute('class', 'btn-primary pull-right');
$submit->setOption('glyphicon', 'log-in');
$submit->setLabel('Log In');
$buttons->add($submit);
$forgot = new Element\Submit('forgot');
$forgot->setAttribute('formnovalidate', true);
$forgot->setAttribute('class', 'btn-warning pull-right');
$forgot->setOption('glyphicon', 'question-sign');
$forgot->setLabel('Forgot Password');
$buttons->add($forgot);
$this->add($buttons);
}
示例10: getNoteForm
/**
* @param Entity\Note $note
* @param string $url
* @param string $action
* @param array $members
* @return \Zend\Form\Form
*/
public function getNoteForm(Entity\Note $note, $url = '', $action = 'add', $members = null)
{
if (is_null($this->noteForm)) {
$builder = new AnnotationBuilder($this->getEntityManager());
$this->noteForm = $builder->createForm($note);
$this->noteForm->setAttribute('action', $url);
$this->noteForm->setAttribute('id', 'noteForm');
$this->noteForm->setHydrator(new DoctrineObject($this->getEntityManager(), 'Secretary\\Entity\\Note'));
$this->noteForm->bind($note);
if ($action == 'edit' && $note->getPrivate() === false) {
$this->noteForm->remove('private');
$group = $note->getGroup();
$membersString = $this->getMembersString(array_keys($members));
$this->noteForm->get('groupHidden')->setValue($group->getId());
$this->noteForm->get('members')->setValue($membersString);
$this->noteForm->getInputFilter()->remove('__initializer__');
$this->noteForm->getInputFilter()->remove('__cloner__');
$this->noteForm->getInputFilter()->remove('__isInitialized__');
$this->noteForm->getInputFilter()->remove('lazyPropertiesDefaults');
} else {
$this->noteForm->get('private')->setAttribute('required', false);
$this->noteForm->getInputFilter()->get('private')->setRequired(false);
}
}
return $this->noteForm;
}
示例11: getForm
public function getForm($hasCaptcha, $url = '', $captchaPath = '')
{
if (!$this->form) {
$form = new Form();
$txtUser = new Element\Text('username');
$txtUser->setLabel('User Name')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'User name');
$password = new Element\Password('password');
$password->setLabel('Password')->setAttribute('class', 'form-control')->setAttribute('placeholder', 'Password');
$remember = new Element\Checkbox('remember');
$remember->setLabel('Save authentication?')->setAttribute('class', 'form-control');
if ($hasCaptcha) {
$captchaImage = new Image();
$captchaImage->setFont('./data/font/CAMBRIA.TTC')->setWidth(200)->setHeight(60)->setDotNoiseLevel(40)->setLineNoiseLevel(4)->setExpiration(90);
$captchaImage->setImgUrl($url);
$captchaImage->setImgDir($captchaPath);
$captcha = new Element\Captcha('isHuman');
$captcha->setCaptcha($captchaImage)->setAttributes(array('class' => 'form-control'));
$form->add($captcha);
}
$form->setAttribute('class', 'form-horizontal');
$form->add($txtUser);
$form->add($password);
$form->add($remember);
$this->form = $form;
}
return $this->form;
}
示例12: getForm
public function getForm(array $companyTypes, array $statusList)
{
if (!$this->form) {
$companyId = new Element\Hidden();
$companyId->setName('companyId');
$name = new Element\Text();
$name->setLabel('Name')->setName("name")->setAttribute('class', 'form-control');
$phone = new Element\Text();
$phone->setLabel('Phone')->setName("phone")->setAttribute('class', 'form-control');
$address = new Element\Textarea();
$address->setLabel('Address')->setName("address")->setAttribute('class', 'form-control');
$website = new Element\Url();
$website->setLabel('Website')->setName("website")->setAttribute('class', 'form-control');
$type = new Element\Select();
$type->setName("type")->setLabel('Type')->setAttribute('class', 'form-control')->setValueOptions($companyTypes);
$status = new Element\Select();
$status->setName("status")->setLabel('Status')->setAttribute('class', 'form-control')->setValueOptions($statusList);
$form = new Form();
$form->setAttribute('class', 'form-horizontal');
$form->add($companyId);
$form->add($name);
$form->add($phone);
$form->add($address);
$form->add($website);
$form->add($type);
$form->add($status);
$this->form = $form;
}
return $this->form;
}
示例13: __invoke
public function __invoke(Form $form)
{
$form->setAttribute('class', self::DEFAULT_FORM_CLASS);
foreach ($form->getElements() as $element) {
/*
* controls how far the form indents into
* the page using Twitter:Bootstrap CSS
*
*/
$defLabelAttributes = array('class' => self::DEFAULT_LABEL_CLASS);
$element->setLabelAttributes($defLabelAttributes);
$element->setAttribute('class', self::DEFAULT_INPUT_CLASS);
/*
* set the id attribute of all inputs to be equal to their names
*
* makes life simple when trying to make the view
* dynamic
*/
$element->setAttribute('id', $element->getName());
}
/*
* the submit button is a little different, it uses
* a button class to proper rendering
*
*/
$form->get('submit')->setAttribute('class', self::DEFAULT_SUBMIT_BUTTON_CLASS);
return $form;
}
示例14: getForm
public function getForm()
{
if (!$this->form) {
$hidId = new Element\Hidden();
$hidId->setName('routeId');
$txtName = new Element\Text();
$txtName->setLabel('Route Name')->setName("name")->setAttribute('class', 'form-control');
$txtRoute = new Element\Text();
$txtRoute->setLabel('Route')->setName("route")->setAttribute('class', 'form-control');
$txtModule = new Element\Text();
$txtModule->setLabel("Module")->setName('module')->setAttribute('class', 'form-control');
$txtController = new Element\Text();
$txtController->setLabel("Controller")->setName('controller')->setAttribute('class', 'form-control');
$txtConstraints = new Element\Textarea();
$txtConstraints->setLabel("Constraints")->setName('constraints')->setAttribute('class', 'form-control');
$form = new Form();
$form->setAttribute('class', 'form-horizontal');
$form->add($hidId);
$form->add($txtName);
$form->add($txtRoute);
$form->add($txtModule);
$form->add($txtController);
$form->add($txtConstraints);
$this->form = $form;
}
return $this->form;
}
示例15: prepareForm
/**
* Prepares a new instance of \Zend\Form
*/
public function prepareForm()
{
$this->settingsForm = new Form($this->getView()->Translate('settings'));
$this->settingsForm->setAttribute('method', 'get');
if (!in_array('columnsForm', $this->displaySettings)) {
return;
}
$this->settingsForm->add(new ColumnSettingsFieldset($this->tableModel));
}