本文整理汇总了PHP中FormControl类的典型用法代码示例。如果您正苦于以下问题:PHP FormControl类的具体用法?PHP FormControl怎么用?PHP FormControl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FormControl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* Validates the data contained in the given form control using the validator
* specified by the given form control.
*
* @param FormControl $control
*
* @return boolean
*/
public function validate($control)
{
if (preg_match($this->getRegexpForValidator($control->getValidator()), $control->getData())) {
return TRUE;
}
return FALSE;
}
示例2: getControl
/**
* Generates control's HTML element.
* @return Html
*/
public function getControl()
{
$control = FormControl::getControl();
// skopirovany kod z SelectBox.php
if ($this->isFirstSkipped()) {
$items = $this->items;
reset($items);
$control->data['nette-empty-value'] = $this->areKeysUsed() ? key($items) : current($items);
}
$selected = $this->getValue();
$this->selected = is_array($selected) ? array_flip($selected) : array($selected => TRUE);
$this->formatOptions($this->items, $control);
return $control;
}
示例3: __construct
public function __construct($formName, $courseList)
{
parent::__construct();
$this->setName($formName);
$this->addHidden('id');
$this->addHidden('recipientsCount')->withData(0);
$this->addHidden('enqueuedmsg')->withData(translateFN('Newsletter inoltrata per l\'invio'));
$userType = FormControl::create(FormControl::SELECT, 'userType', translateFN('Tipo Utente'))->withData(array(0 => translateFN('Scegli il tipo...'), AMA_TYPE_AUTHOR => translateFN('Autore'), AMA_TYPE_STUDENT => translateFN('Studente'), AMA_TYPE_TUTOR => translateFN('Tutor'), AMA_TYPE_SWITCHER => translateFN('Switcher'), 9999 => translateFN('Tutti')), 0)->setRequired()->setValidator(FormValidator::POSITIVE_NUMBER_VALIDATOR);
$userPlatformStatus = FormControl::create(FormControl::SELECT, 'userPlatformStatus', translateFN('Stato Studente nella Piattaforma'))->withData(array(-1 => translateFN('Scegli lo stato...'), ADA_STATUS_PRESUBSCRIBED => translateFN('Non Confermato'), ADA_STATUS_REGISTERED => translateFN('Confermato')), -1)->setAttribute('disabled', 'true')->setValidator(FormValidator::POSITIVE_NUMBER_VALIDATOR);
$userCourseStatus = FormControl::create(FormControl::SELECT, 'userCourseStatus', translateFN('Stato Studente nel corso selezionato'))->withData(array(-1 => translateFN('Scegli lo stato...'), ADA_SERVICE_SUBSCRIPTION_STATUS_UNDEFINED => translateFN('In visita'), ADA_SERVICE_SUBSCRIPTION_STATUS_REQUESTED => translateFN('Preiscritto'), ADA_SERVICE_SUBSCRIPTION_STATUS_ACCEPTED => translateFN('Iscritto'), ADA_SERVICE_SUBSCRIPTION_STATUS_SUSPENDED => translateFN('Rimosso'), ADA_SERVICE_SUBSCRIPTION_STATUS_COMPLETED => translateFN('Completato')), -1)->setAttribute('disabled', 'true')->setValidator(FormValidator::POSITIVE_NUMBER_VALIDATOR);
$this->addFieldset(translateFN('Filtro') . ' ' . translateFN('Utenti'), 'userChoice')->withData(array($userType, $userPlatformStatus, $userCourseStatus));
$courseList[0] = translateFN('Scegli il corso...');
$courseSel = FormControl::create(FormControl::SELECT, 'idCourse', translateFN('Corso'))->withData($courseList, 0)->setAttribute('disabled', 'true')->setValidator(FormValidator::POSITIVE_NUMBER_VALIDATOR);
$instanceSel = FormControl::create(FormControl::SELECT, 'idInstance', translateFN('Istanza Corso'))->setAttribute('disabled', 'true')->setValidator(FormValidator::POSITIVE_NUMBER_VALIDATOR);
$this->addFieldset(translateFN('Filtro') . ' ' . translateFN('Corsi'), 'courseChoice')->withData(array($courseSel, $instanceSel));
$this->setSubmitValue(translateFN('Invia Newsletter'));
}
示例4: get
/**
* Get this control for display
* @param Theme $theme The theme to use for rendering
* @return string The output
*/
public function get(Theme $theme)
{
$this->vars['element'] = $this->get_setting('wrap_element', 'div');
$content = '';
foreach ($this->value as $key => $data) {
// Push the $key of this array item into the control's name
$this->each(function (FormControl $control) use($key) {
$control->add_input_array($key);
});
$content .= $this->get_contents($theme);
// Pop the key of this array item out of the control's name
$this->each(function (FormControl $control) {
$control->pop_input_array();
});
}
$this->vars['content'] = $content;
return FormControl::get($theme);
}
示例5: controls_js
/**
* Render the controls.init script prior to the supplied script only if it hasn't already been rendered
* @param string $out An existing script that depends on controls.init
* @return string The script with the controls.init script prepended, if needed
*/
public function controls_js($out)
{
if (FormControl::$controls_js == false) {
$js = '
<script type="text/javascript">
if(controls==undefined){
var controls = {
init:function(fn){
if(fn!=undefined){
controls.inits.push(fn);
}else{
for(var i in controls.inits){
controls.inits[i]();
}
}
},
inits:[]
};
}
$(function(){
controls.init();
});
</script>';
$out = $js . $out;
FormControl::$controls_js = true;
}
return $out;
}
示例6: __construct
/**
* @author giorgio 29/mag/2013
*
* added extra parameter to constructor to allow editing of student confirmed registration
*
*/
public function __construct($languages = array(), $allowEditProfile = false, $allowEditConfirm = false, $action = null)
{
parent::__construct();
$this->addHidden('id_utente')->withData(0);
/*
* @author:Sara 20/05/2014
* Workaround to remove the Google-Chrome autocomplete functionality.
*/
$j = 'return remove_false_element()';
$this->setOnSubmit($j);
$false_username = FormControl::create(FormControl::INPUT_TEXT, 'false_username', '');
$false_password = FormControl::create(FormControl::INPUT_PASSWORD, 'false_password', '');
$false_elements_fieldset = FormControl::create(FormControl::FIELDSET, 'false_elements_fieldset', '');
$false_elements_fieldset->setHidden();
$false_elements_fieldset->withData(array($false_username, $false_password));
$this->addControl($false_elements_fieldset);
$this->addPasswordInput('password', translateFN('Password'));
//->setValidator(FormValidator::PASSWORD_VALIDATOR);
$this->addPasswordInput('passwordcheck', translateFN('Conferma la password'));
/**
* If the swithcer does not use this form to edit her own
* profile, the avatar upload must be disabled
*/
if ($_SESSION['sess_userObj']->getType() != AMA_TYPE_SWITCHER || !$allowEditConfirm) {
$this->addFileInput('avatarfile', translateFN('Seleziona un file immagine per il tuo avatar'));
$this->addTextInput('avatar', NULL);
}
if ($action != null) {
$this->setAction($action);
}
/// $this->addTextInput('telefono', translateFN('Telefono'));
$telefono = FormControl::create(FormControl::INPUT_TEXT, 'telefono', translateFN('Telefono'));
$cap = FormControl::create(FormControl::INPUT_TEXT, 'cap', translateFN('cap'));
$citta = FormControl::create(FormControl::INPUT_TEXT, 'citta', translateFN('Città'));
$indirizzo = FormControl::create(FormControl::INPUT_TEXT, 'indirizzo', translateFN('Indirizzo'));
$provincia = FormControl::create(FormControl::INPUT_TEXT, 'provincia', translateFN('Provincia'));
$countries = countriesList::getCountriesList($_SESSION['sess_user_language']);
$nazione = FormControl::create(FormControl::SELECT, 'nazione', translateFN('Nazione'));
$nazione->withData($countries);
$this->addFieldset(translateFN('Dati residenza'), 'residenza')->withData(array($indirizzo, $cap, $citta, $provincia, $nazione, $telefono));
// $this->addTextInput('indirizzo', translateFN('Indirizzo'));
// $this->addTextInput('citta', translateFN('Città'));
// $this->addTextInput('provincia', translateFN('Provincia'));
/*
$countries = countriesList::getCountriesList($_SESSION['sess_user_language']);
$this->addSelect(
'nazione',
translateFN('Nazione'),
$countries,
'IT');
*
*/
$this->addTextInput('codice_fiscale', translateFN('Cod. Fiscale'));
/**
* @author giorgio 29/mag/2013
*
* added select field to allow editing of user confirmed registration status
*/
if ($allowEditConfirm) {
$this->addSelect('stato', translateFN('Confermato'), array(ADA_STATUS_PRESUBSCRIBED => translateFN('No'), ADA_STATUS_REGISTERED => translateFN('Si')), 0);
}
//->setValidator(FormValidator::PASSWORD_VALIDATOR);
if ($allowEditProfile) {
$this->addTextarea('profilo', translateFN('Il tuo profilo utente'));
}
$layoutsAr = array('' => translateFN('seleziona un layout'));
$layoutObj = new UILayout();
$avalaibleLayoutAr = $layoutObj->getAvailableLayouts();
$layouts = array_merge($layoutsAr, $avalaibleLayoutAr);
$this->addSelect('layout', translateFN('Layout'), $layouts, 0);
if (is_array($languages) && count($languages) > 0) {
$languagesAr[0] = translateFN('seleziona una lingua');
$languages = array_replace($languagesAr, $languages);
// $languages = array_merge($languagesAr,$languages);
$this->addSelect('lingua', translateFN('Lingua'), $languages, 0);
}
}
示例7: notifyRule
/**
* New rule or condition notification callback.
* @param Rule
* @return void
*/
public function notifyRule(Rule $rule)
{
if ($rule->type === Rule::VALIDATOR && is_string($rule->operation) && strcasecmp($rule->operation, ':mimeType') === 0) {
$this->control->accept = $rule->arg;
}
parent::notifyRule($rule);
}
示例8: set_value
public function set_value($value, $manually = true)
{
if ($value != false) {
$this->returned_value = $value;
}
return parent::set_value($value, $manually);
}
示例9: notifyRule
public function notifyRule(Rule $rule)
{
if (is_string($rule->operation) && strcasecmp($rule->operation, ':float') === 0) {
$this->addFilter(array(__CLASS__, 'filterFloat'));
}
parent::notifyRule($rule);
}
示例10: validate
/**
* This control only validates if it's clicked
* @return array If empty, no errors. One string element describing each error
*/
public function validate()
{
if (isset($_POST[$this->input_name()])) {
return parent::validate();
}
return array();
}
示例11: get
public function get(Theme $theme)
{
$silos = Media::dir();
foreach ($silos as &$silo) {
$silo->path_slug = Utils::slugify($silo->path);
}
$this->vars['silos'] = $silos;
return parent::get($theme);
}
示例12: attached
/**
* This method will be called when the component (or component's parent)
* becomes attached to a monitored object. Do not call this method yourself.
* @param IComponent
* @return void
*/
protected function attached($form)
{
if ($form instanceof Form) {
if ($form->getMethod() !== Form::POST) {
throw new InvalidStateException('File upload requires method POST.');
}
$form->getElementPrototype()->enctype = 'multipart/form-data';
}
parent::attached($form);
}
示例13: get
public function get(Theme $theme)
{
$this->properties['type'] = 'hidden';
$this->properties['data-facet-config'] = json_encode($this->properties['data-facet-config']);
$this->set_template_properties('div', array('id' => $this->get_visualizer(), 'data-target' => $this->get_id()));
return parent::get($theme);
}
示例14: get
/**
* Produce HTML output for this text control.
*
* @param boolean $forvalidation True if this control should render error information based on validation.
* @return string HTML that will render this control in the form
*/
public function get(Theme $theme)
{
$this->vars['options'] = $this->options;
$this->settings['internal_value'] = true;
return parent::get($theme);
}
示例15: getControl
/**
* Generates control's HTML element.
* @return Nette\Web\Html
*/
public function getControl()
{
$control = parent::getControl();
$control->value = $this->translate($this->caption);
return $control;
}