christiansalazar avatar christiansalazar committed 61308e2

EYuiFormEditor demo

Comments (0)

Files changed (10)

protected/config/main.php

 return array(
 	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
 	'name'=>'My Web Application',
-
 	// preloading 'log' component
 	'preload'=>array('log'),
 

protected/controllers/ExampleController.php

 		$this->render('eyuiform'
 			,array('user'=>$user,'validationModel'=>EYuiFormDb::newModel($user)));
 	}
+	public function actionEYuiForm2(){
+	
+		// TblUser will provide extra validation for your form
+		// in order to do that, it must implements: EYuiFormIValidator
+		//
+		$user = TblUser::model()->findByPk(1);
+
+		/*
+			please note here:
+			
+			If you decide not use EYuiFormDb then use:
+				$this->render('eyuiform',array('model'=>YourClass::model()));
+			but in YourClass.php you must implement:
+				EYuiFormIStorage.php
+				and
+				EYuiFormIValidator.php
+			this two interfaces ensure YourClass has the appropiated required methods
+			to work togheter with EYuiForm.
+		*/
+		$this->render('eyuiform2'
+			,array('user'=>$user,'validationModel'=>EYuiFormDb::newModel($user)));
+	}
+	public function actionEYuiFormEditor(){
+		$this->render('eyuiformeditor');
+	}
 	
 	public function actionEYuiAjaxAction() 
 	{ 

protected/data/eyuiformdb-sqlite-schema.sql

- CREATE TABLE eyuiformdb (
-    id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
-    model_id INTEGER NOT NULL,
-    form_id VARCHAR(45) NOT NULL,
-    field_name VARCHAR(45) NOT NULL,
+CREATE TABLE eyuiformdb (
+	id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+	model_id INTEGER NOT NULL,
+	form_id VARCHAR(45) NOT NULL,
+	field_name VARCHAR(45) NOT NULL,
 	field_value VARCHAR(1024) NOT NULL
 );

protected/data/eyuiformeditordb-sqlite-schema.sql

+CREATE TABLE eyuiformeditordb (
+	id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+	model_id INTEGER NOT NULL,
+	form_id VARCHAR(45) NOT NULL,
+	item INTEGER NOT NULL,
+	parent_id INTEGER,
+	item_id VARCHAR(45) NOT NULL,
+	label VARCHAR(250) NOT NULL,
+	descr VARCHAR(250),
+	position INTEGER,
+	data VARCHAR(1024) NOT NULL
+);

protected/data/schema.mysql.sql

-CREATE TABLE tbl_user (
-    id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
-    username VARCHAR(128) NOT NULL,
-    password VARCHAR(128) NOT NULL,
-    email VARCHAR(128) NOT NULL
-);
-
-INSERT INTO tbl_user (username, password, email) VALUES ('test1', 'pass1', 'test1@example.com');
-INSERT INTO tbl_user (username, password, email) VALUES ('test2', 'pass2', 'test2@example.com');
-INSERT INTO tbl_user (username, password, email) VALUES ('test3', 'pass3', 'test3@example.com');
-INSERT INTO tbl_user (username, password, email) VALUES ('test4', 'pass4', 'test4@example.com');
-INSERT INTO tbl_user (username, password, email) VALUES ('test5', 'pass5', 'test5@example.com');
-INSERT INTO tbl_user (username, password, email) VALUES ('test6', 'pass6', 'test6@example.com');
-INSERT INTO tbl_user (username, password, email) VALUES ('test7', 'pass7', 'test7@example.com');
-INSERT INTO tbl_user (username, password, email) VALUES ('test8', 'pass8', 'test8@example.com');
-INSERT INTO tbl_user (username, password, email) VALUES ('test9', 'pass9', 'test9@example.com');
-INSERT INTO tbl_user (username, password, email) VALUES ('test10', 'pass10', 'test10@example.com');
-INSERT INTO tbl_user (username, password, email) VALUES ('test11', 'pass11', 'test11@example.com');
-INSERT INTO tbl_user (username, password, email) VALUES ('test12', 'pass12', 'test12@example.com');
-INSERT INTO tbl_user (username, password, email) VALUES ('test13', 'pass13', 'test13@example.com');
-INSERT INTO tbl_user (username, password, email) VALUES ('test14', 'pass14', 'test14@example.com');
-INSERT INTO tbl_user (username, password, email) VALUES ('test15', 'pass15', 'test15@example.com');
-INSERT INTO tbl_user (username, password, email) VALUES ('test16', 'pass16', 'test16@example.com');
-INSERT INTO tbl_user (username, password, email) VALUES ('test17', 'pass17', 'test17@example.com');
-INSERT INTO tbl_user (username, password, email) VALUES ('test18', 'pass18', 'test18@example.com');
-INSERT INTO tbl_user (username, password, email) VALUES ('test19', 'pass19', 'test19@example.com');
-INSERT INTO tbl_user (username, password, email) VALUES ('test20', 'pass20', 'test20@example.com');
-INSERT INTO tbl_user (username, password, email) VALUES ('test21', 'pass21', 'test21@example.com');
Add a comment to this file

protected/data/testdrive.db

Binary file modified.

protected/views/example/eyuiform.php

 <h1>EYuiForm Demo</h1>
 
+<p>This form is created using manual specification for pages,groups and fields.</p>
+
 <p>Current selected user is: <?php echo $user->username.",".$user->email; ?></p>
 
 <?php 
 		//'theme'=>'redmond',
 		'jQueryUiEnabled'=>true,
 		'jQueryControl'=>'tabs', // tabs or accordion
-		'jQueryGroupControl'=>'accordion', // use 'accordion' or leave blank
+		'jQueryGroupControl'=>'', // use 'accordion' or leave blank
 		
 		// fielddes are field definitions, used later in each form field when needed.
 		'fielddefs'=>array(

protected/views/example/eyuiform2.php

+<h1>EYuiForm Demo</h1>
+
+<p>This form is created using <?php echo 
+CHtml::link("eyui form editor",array('example/eyuiformeditor')) ?>.</p>
+
+<p>Current selected user is: <?php echo $user->username.",".$user->email; ?></p>
+<?php 
+	// controller provides validationModel wich is an EYuiFormDb instance who will provide you
+	// field values for current user (and provides extra validation too).
+	$this->widget('ext.eyui.EYuiForm',array(
+		'id'=>'form1',	// this is the 'form1'
+		'label'=>'A Big Form',
+		'model'=>$validationModel, // provides user values for this field and specific validation.
+		'submitButtonLabel'=>'Submit Form',
+		'submitErrorText'=>'Please review for errors',
+		'showErrorsLabel'=>'Show Errors',
+		'formSubmittedOkLabel'=>'Form has been saved.',
+		'showErrorResume'=>false,
+		'jQueryUiEnabled'=>true,
+		'jQueryControl'=>'tabs', // tabs or accordion
+		'jQueryGroupControl'=>'', // use 'accordion' or leave blank
+		'descriptionLocation'=>'title', // field description location: 'title' or 'visible'
+		//
+		// Using EYuiFormEditorDb stored fields: 
+		//
+		//	it will load all fields, groups and pages for model: 'mymodelid' and 'form1'
+		//	
+		//  it loads the pages, groups and fields for 'form1' at model 'mymodelid'
+		//	(not the field values itself..! only form structure. the field values are loaded using the validationModel provided)
+		'pages'=>EYuiFormEditorDb::model('mymodelid',"form1"),
+	));
+?>
+

protected/views/example/eyuiformeditor.php

+<h1>EYuiFormEditor Demo</h1>
+<p>
+<?php echo CHtml::link("view form",array('example/eyuiform2')) ?>
+</p>
+
+<?php 
+	/*
+		please ensure that 'mymodelid' and 'form1' are the same values applied to 	eyuidemo\protected\views\example\eyuiform2.php in: 
+			'pages'=>EYuiFormEditorDb::model('mymodelid',"form1"),
+	*/
+$this->widget('ext.eyui.EYuiFormEditor',array(
+	// please be sure 'mymodelid' and 'form1' are the same whenever you need to fill this form
+	// as a final user.
+	'model'=>EYuiFormEditorDb::model('mymodelid',"form1"),
+	//
+	// please note, all texts can be modified using attribute settings:
+	// look at eyuidemo\protected\extensions\eyui\EYuiFormEditor.php for available attributes:
+	// example:
+	//	
+	'tabPagesTitle'=>'Pages',
+	
+));
+?>

protected/views/site/index.php

 <br/>
 <?php echo CHtml::link("Test EYuiForm",array('example/eyuiform'));?>
 <br/>
+<?php echo CHtml::link("Test EYuiForm (using editor)",array('example/eyuiform2'));?>
+<br/>
+<?php echo CHtml::link("Test EYuiFormEditor",array('example/eyuiformeditor'));?>
+<br/>
 <?php echo CHtml::link("Test EYuiAjaxAction",array('example/eyuiajaxaction'));?>
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.