Http://w3note.com/web/49.html
phpcms V9 's System class library has a form class that encapsulates some components of the form, such as editors, picture uploads, time selectors, template selectors, and more, refer to form.class.php. With these components, it is more time-saving and hassle-phpcms to develop the V9 two times. All we have to do is pull these tools out and use them. There are a total of two methods of calling.
First, the view call method
This method is the simplest, but has limitations. When a model in the background defines a field, the type of the form is selected to generate the corresponding form type.
Second, code call method
This method is more flexible, out of the Content module constraints, no longer adhere to the framework of the content model. Here is a football module controller to add information to the method, see the code:
Form Class Location: libs\classes--form.class.php
01 Public functionAddfbteam () {02$levels=$this->level->select (', ', ' id ', ' Level ', ' ', ' id ')); 03if(isset($_post[' Dosubmit '])){ 04$_post[' Football '] =$this->check ($_post[' Football ']); 05if($this->db->insert ($_post[' Football '])) ShowMessage (L (' operation_success '), '? M=football&c=admin_fbteam&a=fblists '); 06}Else{ Pc_base::load_sys_class (' form ', ', 0); 08include $this->ADMIN_TPL (' Fbteam_add '); 09 } 10}
Description: Pc_base::load_sys_class (' form ', ' 0 '), load Form class form.class.php, ' empty parameter ' represents the path to the class file, load the class inside the System class library, and the parameter ' 0 ' means that the class is not instantiated.
The template view for the above method
<TR><thwidth= "a"><Strong><?php echo L (' Football_profile ')?>:</Strong></th><TD><textareaname= "Football[profile]"ID= "Profile"></textarea><?php echo form::editor (' profile ');?></TD></TR>
Description: "Form::editor (' profile ')", which loads the form class and is not instantiated, is intended to use the static method call editor, where the parameter "profile" represents the ID of the form.
This is only called the Form class editor call, the other table monotone method similar, regardless of what form is called, first of all to load the System class library form class, and then in the template Call Form class form method, such as timesheet, form::d ate (' football[formed] ', date (' Y-m-d '), 0), picture upload form::images (' football[badge] ', ' badge ', ' ', ' Football ').