本文整理汇总了PHP中Zend_Form::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form::__construct方法的具体用法?PHP Zend_Form::__construct怎么用?PHP Zend_Form::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form
的用法示例。
在下文中一共展示了Zend_Form::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(array $values = array(), $insert = false, $options = array())
{
parent::__construct($options);
$this->setName($insert ? 'addproject' : 'editproject')->setAction('#')->setMethod('post')->setAttrib('id', $insert ? 'addproject' : 'editproject');
# name
$name = $this->createElement('text', 'name')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'default_form_error_empty_value')))->addValidator('StringLength', true, array('min' => 3, 'max' => 255, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'default_form_error_length', Zend_Validate_StringLength::TOO_SHORT => 'default_form_error_length')))->setRequired(true)->setValue(isset($values['name']) ? $values['name'] : null)->setLabel('project_admin_field_name');
# name-jp
$namejp = $this->createElement('text', 'name_jp')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'default_form_error_empty_value')))->addValidator('StringLength', false, array('min' => 3, 'max' => 255, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'default_form_error_length', Zend_Validate_StringLength::TOO_SHORT => 'default_form_error_length')))->setRequired(true)->setValue(isset($values['name_jp']) ? $values['name_jp'] : null)->setLabel('project_admin_field_name_jp');
# episode count
$episodes = $this->createElement('text', 'episode_count')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('Int', false, array('meesages' => array(Zend_Validate_Int::NOT_INT => 'default_form_error_int')))->setValue(isset($values['element_count']) ? $values['element_count'] : null)->setLabel('project_admin_field_episode_count');
# status
$status = $this->createElement('select', 'status')->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'default_form_error_empty_value')))->setLabel('project_admin_field_status')->setRequired(true)->setValue(isset($values['status']) ? $values['status'] : 'planned')->setMultiOptions(array('planned' => 'project_status_planned', 'progress' => 'project_status_progress', 'pending' => 'project_status_pending', 'completed' => 'project_status_completed', 'dropped' => 'project_status_dropped', 'licensed' => 'project_status_licensed'));
# desctiption
$description = $this->createElement('textarea', 'description');
$description->setValue(isset($values['description']) ? $values['description'] : null)->setRequired(true)->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'default_form_error_empty_value')))->setAttrib('cols', 40)->setAttrib('rows', 15)->setLabel('description');
$poster = $this->createElement('text', 'poster')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'default_form_error_empty_value')))->addValidator('StringLength', false, array('min' => 5, 'max' => 255, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'default_form_error_length', Zend_Validate_StringLength::TOO_SHORT => 'default_form_error_length')))->setRequired(true)->setValue(isset($values['poster']) ? $values['poster'] : null)->setLabel('project_admin_field_poster');
$miniposter = $this->createElement('text', 'mini_poster')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'default_form_error_empty_value')))->addValidator('StringLength', false, array('min' => 5, 'max' => 255, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'default_form_error_length', Zend_Validate_StringLength::TOO_SHORT => 'default_form_error_length')))->setRequired(true)->setValue(isset($values['mini_poster']) ? $values['mini_poster'] : null)->setLabel('project_admin_field_mini_poster');
$uTable = Doctrine::getTable('User_Model_User');
$users = $uTable->getMultiOptions();
$leaders = $this->createElement('multiselect', 'leaders');
$leaders->setMultiOptions($users)->setLabel('project_admin_field_leader')->setValue(isset($values['Projects_Model_Leader']) ? $values['Projects_Model_Leader'] : array());
$private = $this->createElement('radio', 'private')->setMultiOptions(array('yes' => 'yes_term', 'no' => 'no_term'))->setLabel('project_admin_field_private')->setValue(isset($values['private']) ? $values['private'] : 'yes');
# add elements to the form
$this->addElement($name)->addElement($namejp)->addElement($episodes)->addElement($status)->addElement($description)->addElement($poster)->addElement($miniposter)->addElement($leaders)->addElement($private)->addElement('submit', $insert ? 'add' : 'update', array('label' => $insert ? 'add' : 'update', 'class' => 'button'));
}
示例2: __construct
public function __construct($id)
{
$options = new Zend_Config_Ini(dirname(__FILE__) . '/EditCP.ini', 'fields');
parent::__construct($options);
$this->id->setValue($id);
// $this->setAction('/admin/pages');
}
示例3: __construct
public function __construct(array $dataBusinessId, $options = null)
{
parent::__construct($options);
$this->setName('frmEmployee');
$this->setMethod('post');
$name = new Zend_Form_Element_Text('name');
$name->setLabel('Employee name');
$name->setAttrib('maxlength', 80);
$name->setRequired(true);
$name->addValidator(new Zend_Validate_NotEmpty());
$this->addElement($name);
$age = new Zend_Form_Element_Text('age');
$age->setLabel('Employee age');
$age->addValidator(new Zend_Validate_Int());
$this->addElement($age);
$businessId = new Zend_Form_Element_Select('business_id');
$businessId->setLabel('Business');
$businessId->setRequired(true);
$businessId->addValidator(new Zend_Validate_NotEmpty());
$businessId->addValidator(new Zend_Validate_Int());
$businessId->addMultiOptions($dataBusinessId);
$this->addElement($businessId);
$submit = new Zend_Form_Element_Submit('bt_submit');
$submit->setLabel('Save');
$this->addElement($submit);
}
示例4: __construct
/**
* Constructor.
*
* Turns off Zend_Form translation before calling the parent constructor.
*
* @param mixed $options Set of options for configuring the form.
*/
public function __construct($options = null)
{
// Turn off the translator as this will be done in PHPTAL.
$this->setDisableTranslator(true);
// Call the parent constructor to set up everything else.
parent::__construct($options);
}
示例5: __construct
public function __construct($options = null)
{
parent::__construct();
$this->setName('layout_form');
$this->addElementPrefixPath('Oibs_Decorators', 'Oibs/Decorators/', 'decorator');
$this->removeDecorator('Errors');
$this->removeDecorator('HtmlTag');
$this->removeDecorator('Label');
//$this->setAction($this->_generateActionUrl());
$layout_select = new Zend_Form_Element_Select('layout_select');
$layout_select->setAttrib('onchange', '$("#submitLayoutSelection").click();');
$layout_select->removeDecorator('Errors');
$layout_select->removeDecorator('Label');
$layout_select->removeDecorator('HtmlTag');
/*foreach($options as $language)
$translation_select->addMultiOption($language['iso6391_lng'], $language['name_lng']);
*/
$layout_select->addMultiOption('default', 'Default');
$layout_select->addMultiOption('custom', 'Custom');
//$layout_select->setValue($this->_getCurrentLayoutSelect());
$layout_select->setValue('default');
$submit = new Zend_Form_Element_Submit('submitLayoutSelection');
$submit->removeDecorator('DtDdWrapper');
$submit->setAttrib('style', 'display: none;');
$this->addElements(array($layout_select, $submit));
}
示例6: __construct
/**
* Override the base form constructor.
*
* @param null $options
*/
public function __construct($options = null)
{
$this->_initializePrefixes();
$this->setDecorators(array('FormElements', 'Form'));
parent::__construct($options);
$this->_initializeFieldColSize();
}
示例7: __construct
public function __construct($options = null)
{
parent::__construct($options);
$emailCategoryOptionList = array('Invite non-sparks to join campaign' => $this->getView()->translate('Admin_Non-Sparks_Invitation'), 'Invite sparks to join campaign' => $this->getView()->translate('Admin_Sparks_Invitation'), 'Send mail to sparks' => $this->getView()->translate('Admin_Send_Mail_To_Sparks'));
$emailCategory = new Zend_Form_Element_Select('emailCategory');
$emailCategory->setMultiOptions($emailCategoryOptionList);
$emailList = new Zend_Form_Element_Textarea('emailList');
$emailList->setAttribs(array('rows' => 5, 'cols' => 150, 'onChange' => 'datetable()'))->addFilter('StripTags')->addFilter('StringTrim')->addValidators(array(array('StringLength', false, array(0, 65535))));
$subject = new Zend_Form_Element_Text('subject');
$subject->setAttribs(array('size' => 150))->addFilter('StringTrim');
$message = new Zend_Form_Element_Textarea('message');
$message->setAttribs(array('rows' => 30, 'cols' => 150))->addFilter('StripTags')->addFilter('StringTrim')->addValidators(array(array('StringLength', false, array(0, 65535))));
$optionList = array();
$campaign = new Campaign();
$campaigns = $campaign->fetchAll(null, "id desc", null, null);
foreach ($campaigns as $campaign) {
$optionList[$campaign->id] = $campaign->name;
}
$optionList['0'] = $this->getView()->translate('ADMIN_NOT_AUTO_INVITATION');
$campaignId = new Zend_Form_Element_Select('campaignId');
$campaignId->setMultiOptions($optionList);
$code_source = new Zend_Form_Element_Text('code_source');
$code_source->addFilter('StringTrim');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel($this->getView()->translate('INVITATION_MAIL_SEND'));
$this->addElements(array($emailCategory, $emailList, $subject, $message, $campaignId, $code_source, $submit));
}
示例8: __construct
public function __construct($path)
{
parent::__construct($path);
$formfield = new App_Form_Field();
$accountHeader = $formfield->field('Text', 'accountHeader', '', '', 'txt_put', '', true, '', '', '', '', '', '', '');
$glcodeDescription = new Zend_Form_Element_Textarea('glcodeDescription', array('rows' => 3, 'cols' => 25));
$glcodeDescription->setAttrib('id', 'glcodeDescription');
$glcodeDescription->setRequired(true)->addValidators(array(array('NotEmpty')));
$product = $formfield->field('Select', 'product', '', '', 'txt_put', '', true, '', '', '', '', '', '', '');
$product->setAttrib('onchange', 'getGlcode("' . $path . '",this.value)');
$offerproduct = $formfield->field('Select', 'offerproduct', '', '', 'txt_put', '', '', '', '', '', '', '', '', '');
$officelevel = $formfield->field('Select', 'officelevel', '', '', '', '', '', '', '', '', '', '', 0, 0);
$officelevel->setRegisterInArrayValidator(false);
$officelevel->setAttrib('onchange', 'getoffice("' . $path . '",this.value)');
$office = $formfield->field('Select', 'office', '', '', '', '', '', '', '', '', '', '', 0, 0);
$office->setRegisterInArrayValidator(false);
$subheader = $formfield->field('Text', 'subheader', '', '', 'txt_put', '', '', '', '', '', '', '', '', '');
$glsubaccountdescription = new Zend_Form_Element_Textarea('glsubaccountdescription', array('rows' => 3, 'cols' => 25));
$glsubaccountdescription->setAttrib('id', 'glsubaccountdescription');
$submit = $formfield->field('Submit', 'Save', '', '', '', 'holiday1', '', '', '', '', '', '', '', '');
$this->addElements(array($submit, $accountHeader, $glcodeDescription, $subheader, $glsubaccountdescription, $product, $offerproduct, $officelevel, $office));
$glcodeHiddenId = new Zend_Form_Element_Hidden('hidden_glcodeid');
$glsubcodeHiddenId = new Zend_Form_Element_Hidden('hidden_glsubcodeid');
$submit = new Zend_Form_Element_Submit('Submit');
$submit->setAttrib('class', 'holiday');
$this->addElements(array($submit, $glcodeHiddenId, $glsubcodeHiddenId));
}
示例9: __construct
public function __construct($options = null)
{
parent::__construct($options);
$translate = Zend_Registry::get('Zend_Translate');
$language = $translate->getLocale();
$baseurl = Zend_Controller_Front::getInstance()->getBaseUrl();
$actionUrl = $baseurl . '/' . $language . '/account/fetchpassword';
$this->setName('fetchpassword_form');
$this->setAction($actionUrl);
$this->addElementPrefixPath('Oibs_Decorators', 'Oibs/Decorators/', 'decorator');
$mailvalid = new Zend_Validate_EmailAddress();
$mailvalid->setMessage('email-invalid', Zend_Validate_EmailAddress::INVALID);
$mailvalid->setMessage('email-invalid-hostname', Zend_Validate_EmailAddress::INVALID_HOSTNAME);
$mailvalid->setMessage('email-invalid-mx-record', Zend_Validate_EmailAddress::INVALID_MX_RECORD);
$mailvalid->setMessage('email-dot-atom', Zend_Validate_EmailAddress::DOT_ATOM);
$mailvalid->setMessage('email-quoted-string', Zend_Validate_EmailAddress::QUOTED_STRING);
$mailvalid->setMessage('email-invalid-local-part', Zend_Validate_EmailAddress::INVALID_LOCAL_PART);
$mailvalid->setMessage('email-length-exceeded', Zend_Validate_EmailAddress::LENGTH_EXCEEDED);
$mailvalid->hostnameValidator->setMessage('hostname-invalid-hostname', Zend_Validate_Hostname::INVALID_HOSTNAME);
$mailvalid->hostnameValidator->setMessage('hostname-local-name-not-allowed', Zend_Validate_Hostname::LOCAL_NAME_NOT_ALLOWED);
$mailvalid->hostnameValidator->setMessage('hostname-unknown-tld', Zend_Validate_Hostname::UNKNOWN_TLD);
$mailvalid->hostnameValidator->setMessage('hostname-invalid-local-name', Zend_Validate_Hostname::INVALID_LOCAL_NAME);
$mailvalid->hostnameValidator->setMessage('hostname-undecipherable-tld', Zend_Validate_Hostname::UNDECIPHERABLE_TLD);
// Username input form element
$username = new Zend_Form_Element_Text('email');
$username->setLabel($translate->_("account-fetchpassword-email"))->removeDecorator('DtDdWrapper')->addFilter('StringtoLower')->setRequired(true)->addValidators(array($mailvalid))->setDecorators(array('FetchPasswordDecorator'));
$hidden = new Zend_Form_Element_Hidden('submittedform');
$hidden->setValue('fetchpassword');
// Form submit buttom element
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel($translate->_("account-fetchpassword-submit"))->removeDecorator('DtDdWrapper')->setAttrib('class', 'fetchpassword-submit left');
// Add elements to form
$this->addElements(array($username, $submit, $hidden));
}
示例10: __construct
public function __construct($options = null)
{
parent::__construct($options);
$resendemail = new Zend_Form_Element_Text('resendemail');
$resendemail->setLabel($this->getView()->translate('To'))->addFilter('StripTags')->addFilter('StringTrim')->addValidator('EmailAddress');
$max_amount = isset($options['max_amount']) ? $options['max_amount'] : 50;
for ($i = 1; $i <= $max_amount; $i++) {
$varName = 'email' . $i;
${$varName} = new Zend_Form_Element_Text('email' . $i);
${$varName}->addFilter('StripTags')->addFilter('StringTrim')->addValidator('EmailAddress');
if ($i == $max_amount) {
${$varName}->setAttrib("style", "width:75%");
}
}
$subject = new Zend_Form_Element_Text('subject');
$subject->setAttribs(array("disabled" => 'disabled'))->addFilter('StringTrim');
$subject->setAttrib("style", "width:75%");
$message = new Zend_Form_Element_Textarea('message');
$message->setAttribs(array('rows' => 5, 'cols' => 100))->addFilter('StripTags')->addFilter('StringTrim')->addValidators(array(array('StringLength', false, array(0, 500))));
$message->setAttrib("style", "width:75%");
$sentMailAmount = new Zend_Form_Element_Hidden('sentMailAmount');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel($this->getView()->translate('INVITATION_MAIL_SEND'));
$this->addElements(array($resendemail, $sentMailAmount, $subject, $message, $submit));
for ($i = 1; $i <= $max_amount; $i++) {
$varName = 'email' . $i;
$this->addElement(${$varName});
}
}
示例11:
function __construct($user)
{
parent::__construct();
$this->setName('Registration');
$this->setMethod('POST');
$this->setAction('/user/update');
$gender = new Zend_Form_Element_Select('gender');
$gender->setLabel('Gender');
$gender->setMultiOptions(array('Male' => 'Male', 'Female' => 'Female'));
$gender->setValue($user->gender);
$email = new Zend_Form_Element_Text('email');
$email->setLabel('Email');
$email->setValue($user->email);
$email->setRequired(true);
$email->addValidator('NotEmpty', true);
$email->addValidator(new User_Models_Forms_Validators_EmailAddress(), true);
$paymentEmail = new Zend_Form_Element_Text('paymentEmail');
$paymentEmail->setLabel('Payment Email');
$paymentEmail->setRequired(true);
$paymentEmail->addValidator('NotEmpty', true);
$paymentEmail->addValidator(new User_Models_Forms_Validators_EmailAddress(), true);
$paymentEmail->setValue($user->paymentEmail);
$countries = new Zend_Form_Element_Select('country');
$countries->setMultiOptions(self::getCountries());
$countries->setLabel('Country');
$countries->addValidator('NotEmpty');
$countries->setValue($user->country);
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Update');
$this->addElements(array($gender, $email, $paymentEmail, $countries, $submit));
}
示例12: __construct
public function __construct($option = null)
{
parent::__construct($option);
$this->setName('register');
$this->setAttrib('class', 'input-group');
$username = new Zend_Form_Element_Text('username');
$username->setRequired(true)->setAttrib('class', "form-control")->addFilter(new Zend_Filter_StringTrim())->addValidator(new Zend_Validate_StringLength(4, 20))->addValidator('regex', true, array('/^[(a-zA-Z0-9)]+$/'))->setAttrib('placeholder', "Хэрэглэгчийн нэр")->addValidator('Db_NoRecordExists', true, array('table' => 'users', 'field' => 'username'))->setLabel("Дүн.мн хэрэглэгчийн бүртгүүлэх хэсэг");
$password = new Zend_Form_Element_Password('password');
$password->setRequired(true)->setAttrib('placeholder', "Нууц үг")->setAttrib('class', "form-control")->addFilter(new Zend_Filter_StringTrim())->addValidator(new Zend_Validate_StringLength(8, 20));
$confirmPassword = new Zend_Form_Element_Password('confirm_password');
$confirmPassword->setAttrib('class', "form-control");
$token = Zend_Controller_Front::getInstance()->getRequest()->getPost('password');
$confirmPassword->setRequired(true)->setAttrib('placeholder', "Нууц үгээ давтана уу?")->setAttrib('class', "form-control")->addFilter(new Zend_Filter_StringTrim())->addValidator(new Zend_Validate_Identical(trim($token)));
$firstname = new Zend_Form_Element_Text('firstname');
$firstname->setAttrib('placeholder', "Таны нэр")->addFilter(new Zend_Filter_StringTrim())->addValidator(new Zend_Validate_NotEmpty())->setAttrib('class', "form-control");
$lastname = new Zend_Form_Element_Text('lastname');
$lastname->setAttrib('placeholder', "Таны овог")->addFilter(new Zend_Filter_StringTrim())->addValidator(new Zend_Validate_NotEmpty())->setAttrib('class', "form-control");
$date = new Zend_Form_Element_Text('date');
$date->setAttrib('placeholder', "Төрсөн он сар өдөр (он-сар-өдөр)")->addFilter(new Zend_Filter_StringTrim())->addValidator(new Zend_Validate_NotEmpty())->setAttrib('class', "form-control");
$email = new Zend_Form_Element_Text('email');
$email->addFilters(array('StringTrim', 'StripTags'))->setAttrib('placeholder', "Таны цахим хаяг")->addValidator('EmailAddress', TRUE)->addValidator('Db_NoRecordExists', true, array('table' => 'users', 'field' => 'E-mail'))->addValidator(new Zend_Validate_NotEmpty())->setAttrib('class', "form-control");
$submit = new Zend_Form_Element_Submit('register');
$submit->setLabel('Бүртгүүлэх')->setAttrib('class', 'btn');
$this->addElement($username);
$this->addElement($password);
$this->addElement($confirmPassword);
$this->addElement($firstname);
$this->addElement($lastname);
$this->addElement($date);
$this->addElement($email);
$this->addElement($submit);
$this->setMethod('post');
}
示例13: __construct
public function __construct($minimumDeposit)
{
parent::__construct($minimumDeposit);
$savings_amount = new Zend_Form_Element_Text('savings_amount');
$savings_amount->addValidators(array(array('Float'), array('GreaterThan', false, array($minimumDeposit - 0.0001, 'messages' => array('notGreaterThan' => 'Minimum
Amount To open a savings account =' . $minimumDeposit)))));
$savings_amount->setAttrib('class', 'txt_put');
$savings_amount->setAttrib('id', 'amount');
$savings_amount->setRequired(true);
$savings_amount->setAttrib('onchange', 'calculateTotalAmount(this.value)');
$memberfirstname = new Zend_Form_Element_MultiCheckbox('memberfirstname');
$memberfirstname->setAttrib('class', 'textfield');
$memberfirstname->setAttrib('id', 'selector');
// $memberfirstname->setRequired(true);
$date1 = new ZendX_JQuery_Form_Element_DatePicker('date1', array('label' => 'Date:'));
$date1->setAttrib('class', 'txt_put');
$date1->setJQueryParam('dateFormat', 'yy-mm-dd');
$date1->setRequired(true);
$memberId = new Zend_Form_Element_Hidden('memberId');
$Type = new Zend_Form_Element_Hidden('Type');
$productId = new Zend_Form_Element_Hidden('productId');
$typeId = new Zend_Form_Element_Hidden('typeId');
$memberTypeIdv = new Zend_Form_Element_Hidden('memberTypeIdv');
$submit = new Zend_Form_Element_Submit('Submit');
$Yes = new Zend_Form_Element_Submit('Yes');
$back = new Zend_Form_Element_Submit('Back');
$this->addElements(array($submit, $savings_amount, $memberfirstname, $memberId, $date1, $productId, $typeId, $Type, $memberTypeIdv, $back, $Yes));
}
示例14: __construct
public function __construct(array $values = array(), $insert = false, $options = array())
{
parent::__construct($options);
$this->setName($insert ? 'addepisoderelease' : 'editepisoderelease')->setAction('#')->setMethod('post')->setAttrib('id', $insert ? 'addepisoderelease' : 'editepisoderelease');
# acodec
$acodec = $this->createElement('text', 'acodec')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'default_form_error_empty_value')))->addValidator('StringLength', false, array('min' => 3, 'max' => 10, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'default_form_error_length', Zend_Validate_StringLength::TOO_SHORT => 'default_form_error_length')))->setRequired(true)->setValue(isset($values['acodec']) ? $values['acodec'] : null)->setLabel('project_admin_field_episode_acodec');
# container
$container = $this->createElement('text', 'container')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'default_form_error_empty_value')))->addValidator('StringLength', false, array('min' => 3, 'max' => 10, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'default_form_error_length', Zend_Validate_StringLength::TOO_SHORT => 'default_form_error_length')))->setRequired(true)->setValue(isset($values['container']) ? $values['container'] : null)->setLabel('project_admin_field_episode_container');
# vcodec
$vcodec = $this->createElement('text', 'vcodec')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'default_form_error_empty_value')))->addValidator('StringLength', false, array('min' => 4, 'max' => 10, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'default_form_error_length', Zend_Validate_StringLength::TOO_SHORT => 'default_form_error_length')))->setRequired(true)->setValue(isset($values['vcodec']) ? $values['vcodec'] : null)->setLabel('project_admin_field_episode_vcodec');
# crc
$crc = $this->createElement('text', 'crc')->addFilter('stringToUpper')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty', true, array('messages' => array(Zend_Validate_NotEmpty::IS_EMPTY => 'default_form_error_empty_value')))->addValidator('Hex', false, array('messages' => array(Zend_Validate_Hex::NOT_HEX => 'project_episode_form_error_crc_hex')))->addValidator('StringLength', false, array('min' => 8, 'max' => 8, 'messages' => array(Zend_Validate_StringLength::TOO_LONG => 'project_episode_form_error_crc_length', Zend_Validate_StringLength::TOO_SHORT => 'project_episode_form_error_crc_length')))->setRequired(true)->setValue(isset($values['crc']) ? $values['crc'] : '00000000')->setLabel('project_admin_field_episode_crc');
# released
if (isset($values['released_at'])) {
if (empty($values['released_at'])) {
$released = 'no';
} else {
$released = 'yes';
}
} else {
$released = 'no';
}
$released = $this->createElement('radio', 'released')->setMultiOptions(array('yes' => 'yes_term', 'no' => 'no_term'))->setLabel('project_admin_field_episode_released')->setValue($released);
# release date
$envConf = Zend_Registry::get('environmentSettings');
$time = empty($values['released_at']) ? time() : strtotime($values['released_at']);
$date = new Zend_Date($time, null, $envConf->locale);
$releaseDate = $this->createElement('text', 'releasedate')->setValue($date->toString(Zend_Date::DATE_SHORT))->setLabel('project_admin_field_episode_release_date');
$iso = $this->createElement('hidden', 'isoDate')->setValue(isset($values['released_at']) ? $values['released_at'] : null);
# add elements to the form
$this->addElement($container)->addElement($vcodec)->addElement($acodec)->addElement($crc)->addElement($released)->addElement($releaseDate)->addElement($iso)->addElement('submit', $insert ? 'add' : 'update', array('label' => $insert ? 'add' : 'update', 'class' => 'button'));
}
示例15: __construct
public function __construct($options = null)
{
parent::__construct($options);
$this->setName('WhatIDoForm');
// image, uploader
$image = new Zend_Form_Element_File('Image');
$image->setLabel('Image:')->setDestination('img/profile')->addValidator('Count', false, 1)->addValidator('Size', false, 10000000)->addValidator('Extension', false, 'jpg,png,gif')->addFilter('Rename', 'WhatIDo.jpg');
// PictureCaption, string
$pictureCaption = new Zend_Form_Element_Textarea('PictureCaption');
$pictureCaption->setLabel('Picture caption:')->setRequired();
// MainText, string
$mainText = new Zend_Form_Element_Textarea('MainText');
$mainText->setLabel('Main text:')->setRequired();
// FooterText, string
$footerText = new Zend_Form_Element_Textarea('FooterText');
$footerText->setLabel('Footer text:')->setRequired();
// LinkText, string
$linkText = new Zend_Form_Element_Text('LinkText');
$linkText->setLabel('Link text:')->setRequired();
// LinkUrl, string
$linkUrl = new Zend_Form_Element_Text('LinkUrl');
$linkUrl->setLabel('Link Url:')->setRequired();
// Submit button
$submit = new Zend_Form_Element_Submit('Submit');
$submit->setLabel('Submit');
$this->addElements(array($image, $pictureCaption, $mainText, $footerText, $linkText, $linkUrl, $submit));
}