function __construct($action, $title = false, $method = false) { parent::__construct($title); $this->action = $action; $this->method = $method; $this->class .= " form"; }
public function __construct($atts = null) { error_log(__CLASS__ . ' is candidate for immediate removal, please change this code!', E_USER_DEPRECATED); // Defaults $this->_attributes['name'] = 'page'; if ($atts instanceof PageModel) { parent::__construct(array('name' => 'page')); $page = $atts; } else { if(isset($atts['model']) && $atts['model'] instanceof PageModel){ // Everything is based off the page. $page = $atts['model']; unset($atts['model']); parent::__construct($atts); } else{ parent::__construct($atts); // BaseURL needs to be set for this to work. //if(!$this->get('baseurl')) return null; // Everything is based off the page. $page = new PageModel($this->get('baseurl')); } } $this->_attributes['baseurl'] = $page->get('baseurl'); $name = $this->_attributes['name']; // I need to get a list of pages to offer as a dropdown for selecting the "parent" page. $f = new ModelFactory('PageModel'); if ($this->get('baseurl')) $f->where('baseurl != ' . $this->get('baseurl')); $opts = PageModel::GetPagesAsOptions($f, '-- No Parent Page --'); $this->addElement( 'pageparentselect', array( 'name' => $name . "[parenturl]", 'title' => 'Parent Page', 'value' => strtolower($page->get('parenturl')), 'options' => $opts ) ); // Title $this->addElement( 'text', array( 'name' => $name . "[title]", 'title' => 'Title', 'value' => $page->get('title'), 'description' => 'Every page needs a title to accompany it, this should be short but meaningful.', 'required' => true ) ); // Rewrite url. $this->addElement( 'pagerewriteurl', array( 'name' => $name . "[rewriteurl]", 'title' => 'Page URL', 'value' => $page->get('rewriteurl'), 'description' => 'Starts with a "/", omit ' . ROOT_URL, 'required' => true ) ); $this->addElement( 'access', array( 'name' => $name . "[access]", 'title' => 'Access Permissions', 'value' => $page->get('access') ) ); $this->addElement( 'pagemetas', array( 'name' => $name . '_meta', 'model' => $page, ) ); // Give me all the skins available on the current theme. $skins = array('' => '-- Site Default Skin --'); foreach(ThemeHandler::GetTheme(null)->getSkins() as $s){ $n = ($s['title']) ? $s['title'] : $s['file']; if($s['default']) $n .= ' (default)'; $skins[$s['file']] = $n; } if(sizeof($skins) > 2){ $this->addElement( 'select', array( 'name' => $name . "[theme_template]", 'title' => 'Theme Skin', 'value' => $page->get('theme_template'), 'options' => $skins ) ); } }
/** * Construct a new Form object * * @param array $atts Array of attribute to assign to this form off the bat. */ public function __construct($atts = null) { if($atts === null){ $atts = []; } // Some defaults if(!isset($atts['method'])) $atts['method'] = 'POST'; if(!isset($atts['orientation'])) $atts['orientation'] = 'horizontal'; parent::__construct($atts); $this->_validattributes = array('accept', 'accept-charset', 'action', 'enctype', 'id', 'method', 'name', 'target', 'style'); // Will get set back to true on form submission for preserving the input values. $this->persistent = false; }