Plz any body help me

how can i send data in server by form use Zend framwork MVC

or give me instraction about zend MVC

Plz any body help me

how can i send data in server by form use Zend framwork MVC

or give me instraction about zend MVC

Hi belayetsumon,

By reading your post topic, which one is right: "Zend From" or "Zend Form"? ;)

It's Zend Form I think..

Ok here is my example form using Zend Form below :

First, We need a class and put it in our library

Make a file and give it a name: "Config.php"

<?php

/*
 * Author: RL Fantasy Design Studio - http://www.RLFantasy.com
 * Date: 27th April 2009
 */

class Core_Form_Config extends Zend_Form {
	
	public function __construct() 
	{
	    // appname textfield
        $app_name = new Zend_Form_Element_Text('app_name');
        $app_name->addFilter('StringTrim')->setRequired(true)->setLabel('Application Name');

        // admin email textfield
        $admin_email = new Zend_Form_Element_Text('admin_email');
        $admin_email->addFilter('StringTrim')->setRequired(true)->setLabel('Admin Email');
        
        // CMS background color
        $cms_bgcolor = new Zend_Form_Element_Text('cms_bgcolor');
        $cms_bgcolor->addFilter('StringTrim')->setRequired(true)->setLabel('CMS Background Color');
        
        // CMS table header background color
        $cms_tableheader_bgcolor = new Zend_Form_Element_Text('cms_tableheader_bgcolor');
        $cms_tableheader_bgcolor->addFilter('StringTrim')->setRequired(true)->setLabel('CMS Table Header BgColor');
        
        // CMS table header font color
        $cms_tableheader_fontcolor = new Zend_Form_Element_Text('cms_tableheader_fontcolor');
        $cms_tableheader_fontcolor->addFilter('StringTrim')->setRequired(true)->setLabel('CMS Table Header Font Color');
        
        // the submit button
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setValue('Save Category');        
        
        $this->addElements ( array ($app_name, $admin_email,$cms_bgcolor,
        	$cms_tableheader_bgcolor,$cms_tableheader_fontcolor,$submit ) );
		$this->addDisplayGroup ( array ('app_name','admin_email','cms_bgcolor',
			'cms_tableheader_bgcolor','cms_tableheader_fontcolor','submit' ), 
			'zend_form',array('style'=>'width:500px'));
		
		$this->addDecorator ( 'FormElements' )->addDecorator ( 'Form' );
	}
	
}

Based on the "Class" name above, you should know where you should put the file on the root, right? Core - Config - Form


Second, okay next...and here is what we have in our "Controller" below :

Give it a name: "ConfigController.php"

<?php
class Cms_ConfigController extends Core_Controller_Cms
/*
 * Author: RL Fantasy Design Studio - http://www.RLFantasy.com
 * Date: 27th April 2009
 * This config is for in the admin page, so we give a name CMS for this class.
 */
{
	/**
	 * The default action - show the home page
	 */
	public function indexAction() 
    {
       $configModel = new ConfigModel();
		if($this->_request->isPost())
		{
			$params = Core_Helper_Filter::filterform ( $this->_getAllParams () );
			$configModel->update(array('config_value'=>$params['app_name']),"config_key='app_name'");
			$configModel->update(array('config_value'=>$params['admin_email']),"config_key='admin_email'");
			$configModel->update(array('config_value'=>$params['cms_bgcolor']),"config_key='cms_bgcolor'");
			$configModel->update(array('config_value'=>$params['cms_tableheader_bgcolor']),"config_key='cms_tableheader_bgcolor'");
			$configModel->update(array('config_value'=>$params['cms_tableheader_fontcolor']),"config_key='cms_tableheader_fontcolor'");
		}
		
		$arr_config = $configModel->getConfigData();
		$configs = array();
		foreach ($arr_config as $config)
			$configs[$config['config_key']] = $config['config_value'];
		
		$form = new Core_Form_Config();
		$form->getElement('app_name')->setValue($configs['app_name']);
		$form->getElement('admin_email')->setValue($configs['admin_email']);
		$form->getElement('cms_bgcolor')->setValue($configs['cms_bgcolor']);
		$form->getElement('cms_tableheader_bgcolor')->setValue($configs['cms_tableheader_bgcolor']);
		$form->getElement('cms_tableheader_fontcolor')->setValue($configs['cms_tableheader_fontcolor']);
		$this->view->form = $form;
		
		$this->setTitle('Config');
    }
}

Third (final), here is what we have in the "Action" below :

Create file and give it a name: "index.phtml", as the controller above is just only have a public function indexAction(), then put the file in folder "config" - I think you must know it already...ok let's forward, take a look what we have in the "Action" :

<?php echo $this->form?>

Wow!! Ain't that too short?? Just one line??? The answer is "YES" :twisted: - That's why I love Zend Framework so much...yes so much !!!

If you have any question feel free to PM or contact me from

Get updated by subscribing to the RSS feed from RL Blog:

Cheers! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.