public function __construct($name) { parent::__construct($name); $this->setAction(OW::getRouter()->urlForRoute('ocsaffiliates.action_signup')); $this->setAjax(); $lang = OW::getLanguage(); $affName = new TextField('name'); $affName->setRequired(true); $affName->setLabel($lang->text('ocsaffiliates', 'affiliate_name')); $this->addElement($affName); $email = new TextField('email'); $email->setRequired(true); $email->setLabel($lang->text('ocsaffiliates', 'email')); $email->addValidator(new EmailValidator()); $this->addElement($email); $password = new PasswordField('password'); $password->setRequired(true); $password->setLabel($lang->text('ocsaffiliates', 'password')); $this->addElement($password); $payment = new Textarea('payment'); $payment->setRequired(true); $payment->setLabel($lang->text('ocsaffiliates', 'payment_details')); $this->addElement($payment); if (OW::getConfig()->getValue('ocsaffiliates', 'terms_agreement')) { $terms = new CheckboxField('terms'); $validator = new RequiredValidator(); $validator->setErrorMessage($lang->text('ocsaffiliates', 'terms_required_msg')); $terms->addValidator($validator); $this->addElement($terms); } $submit = new Submit('signup'); $submit->setValue($lang->text('ocsaffiliates', 'signup_btn')); $this->addElement($submit); $this->bindJsFunction(Form::BIND_SUCCESS, "function(data){\n if ( !data.result ) {\n OW.error(data.error);\n }\n else {\n document.location.reload();\n }\n }"); }
public function Validate() { parent::Validate(); if (!$this->IsValid()) { $this->AddMessage($this->attributeName . ' is missing or empty'); } }
public function isValid($value) { $value = (string) $value; $valid = TRUE; if (trim($value) != '') { if ($this->minLength != -1) { if (strlen($value) < $this->minLength) { $this->addMessage('minLength'); $valid = FALSE; } } if ($this->maxLength != -1) { if (strlen($value) > $this->maxLength) { $valid = FALSE; $this->addMessage('maxLength'); } } if ($this->regexp) { $status = @preg_match($this->regexp, $value); if ($status === FALSE) { $this->addMessage('regexp'); $valid = FALSE; } } if (!$this->allowHtml && self::containsHtml($value)) { $this->addMessage('noHtml'); $valid = FALSE; } } return parent::isValid($value) && $valid; }
/** * Describes the schema and validation rules for this object. This is auto-generated. */ protected function describe() { parent::describe(); // create validators for columns $this->validators["driver"]=array( RequiredValidator::Create("driver is required.") ); $this->validators["name"]=array( RequiredValidator::Create("name is required.") ); // create relations for columns $this->related['accounts']=new Relation($this,'accounts',Relation::RELATION_MANY,'provider.account','provider_id'); }
/** * Describes the schema and validation rules for this object. This is auto-generated. */ protected function describe() { parent::describe(); // create validators for columns $this->validators["provider_id"]=array( RequiredValidator::Create("provider_id is required.") ); $this->validators["name"]=array( RequiredValidator::Create("name is required.") ); // create relations for columns $this->related['inventory']=new Relation($this,'inventory',Relation::RELATION_MANY,'provider.inventory','account_id'); $this->related['keys']=new Relation($this,'keys',Relation::RELATION_MANY,'provider.keys','account_id'); $this->related['provider']=new Relation($this,'provider',Relation::RELATION_SINGLE,'provider.provider','id','provider_id'); }
/** * Describes the schema and validation rules for this object. This is auto-generated. */ protected function describe() { parent::describe(); // create validators for columns $this->validators["account_id"]=array( RequiredValidator::Create("account_id is required.") ); $this->validators["text_id"]=array( RequiredValidator::Create("text_id is required.") ); $this->validators["name"]=array( RequiredValidator::Create("name is required.") ); // create relations for columns $this->related['account']=new Relation($this,'account',Relation::RELATION_SINGLE,'provider.account','id','account_id'); }
public function isValid($value) { $value = (string) $value; $valid = TRUE; if (trim($value) != '') { if (count($this->allowedValues)) { $valid = FALSE; foreach ($this->allowedValues as $allowed) { // cast both to string if ("{$value}" == "{$allowed}") { $valid = TRUE; } } if (!$valid) { $this->addMessage('inList'); } } } return parent::isValid($value) && $valid; }
/** * Class constructor * */ public function __construct(MAILBOX_CMP_NewMessage $component = null) { $language = OW::getLanguage(); parent::__construct('mailbox-new-message-form'); $this->setId('mailbox-new-message-form'); $this->setAjax(true); $this->setAjaxResetOnSuccess(false); $this->setAction(OW::getRouter()->urlFor('MAILBOX_CTRL_Ajax', 'newMessage')); $this->setEmptyElementsErrorMessage(''); $this->setEnctype('multipart/form-data'); $subject = new TextField('subject'); // $subject->setHasInvitation(true); // $subject->setInvitation($language->text('mailbox', 'subject')); $subject->addAttribute('placeholder', $language->text('mailbox', 'subject')); $requiredValidator = new RequiredValidator(); $requiredValidator->setErrorMessage($language->text('mailbox', 'subject_is_required')); $subject->addValidator($requiredValidator); $validatorSubject = new StringValidator(1, 2048); $validatorSubject->setErrorMessage($language->text('mailbox', 'message_too_long_error', array('maxLength' => 2048))); $subject->addValidator($validatorSubject); $this->addElement($subject); $validator = new StringValidator(1, MAILBOX_BOL_AjaxService::MAX_MESSAGE_TEXT_LENGTH); $validator->setErrorMessage($language->text('mailbox', 'message_too_long_error', array('maxLength' => MAILBOX_BOL_AjaxService::MAX_MESSAGE_TEXT_LENGTH))); $textarea = OW::getClassInstance("MAILBOX_CLASS_Textarea", "message"); /* @var $textarea MAILBOX_CLASS_Textarea */ $textarea->addValidator($validator); $textarea->setCustomBodyClass("mailbox"); // $textarea->setHasInvitation(true); // $textarea->setInvitation($language->text('mailbox', 'message_invitation')); $textarea->addAttribute('placeholder', $language->text('mailbox', 'message_invitation')); $requiredValidator = new RequiredValidator(); $requiredValidator->setErrorMessage($language->text('mailbox', 'chat_message_empty')); $textarea->addValidator($requiredValidator); $this->addElement($textarea); $user = OW::getClassInstance("MAILBOX_CLASS_UserField", "opponentId"); /* @var $user MAILBOX_CLASS_UserField */ // $user->setHasInvitation(true); // $user->setInvitation($language->text('mailbox', 'to')); $requiredValidator = new RequiredValidator(); $requiredValidator->setErrorMessage($language->text('mailbox', 'recipient_is_required')); $user->addValidator($requiredValidator); $this->addElement($user); if (OW::getSession()->isKeySet('mailbox.new_message_form_attachments_uid')) { $uidValue = OW::getSession()->get('mailbox.new_message_form_attachments_uid'); } else { $uidValue = UTIL_HtmlTag::generateAutoId('mailbox_new_message'); OW::getSession()->set('mailbox.new_message_form_attachments_uid', $uidValue); } $uid = new HiddenField('uid'); $uid->setValue($uidValue); $this->addElement($uid); $configs = OW::getConfig()->getValues('mailbox'); if (!empty($configs['enable_attachments']) && !empty($component)) { $attachmentCmp = new BASE_CLASS_FileAttachment('mailbox', $uidValue); $attachmentCmp->setInputSelector('#newMessageWindowAttachmentsBtn'); $component->addComponent('attachments', $attachmentCmp); } $submit = new Submit("send"); $submit->setValue($language->text('mailbox', 'send_button')); $this->addElement($submit); if (!OW::getRequest()->isAjax()) { $this->initStatic(); } }
public function __construct($recipientId) { parent::__construct('send-gift-form'); $this->setAjax(true); $this->setAction(OW::getRouter()->urlFor('VIRTUALGIFTS_CTRL_Gifts', 'ajaxSendGift')); $lang = OW::getLanguage(); $tplId = new HiddenField('tplId'); $v = new RequiredValidator(); $v->setErrorMessage($lang->text('virtualgifts', 'gift_not_selected')); $tplId->addValidator($v); $this->addElement($tplId); $message = new Textarea('message'); $this->addElement($message); $recipient = new HiddenField('recipientId'); $recipient->setValue($recipientId); $this->addElement($recipient); $user = BOL_UserService::getInstance()->getUserName($recipientId); $isPrivate = new CheckboxField('isPrivate'); $isPrivate->setLabel($lang->text('virtualgifts', 'send_private_gift', array('user' => $user))); $this->addElement($isPrivate); $submit = new Submit('send'); $submit->setValue($lang->text('virtualgifts', 'btn_send')); $this->addElement($submit); $js = 'owForms["' . $this->getName() . '"].bind("success", function(data){ if ( data.error != undefined ){ OW.error(data.error); } if ( data.message != undefined ){ OW.info(data.message); } sendGiftFloatBox.close() });'; OW::getDocument()->addOnloadScript($js); }