Add A Textfield In Form With Out Model Class In YII?

Feb 24, 2011

I need to add a text field in YII form in which i am not specify any model class name. But I need to process that value in the action method inside the controller class.

ie

I need to add a text field as

<div class="row">
<input type="text" name="test" id="test" >
</div>

I add text field as

<?php echo $form->textField($model['groupModel'],'group_name',array('size'=>60,'maxlength'=>128)); ?>

But i do't want to specify any model name with the new text field..

ADVERTISEMENT

Mvc - Difference Between A Library Class And A Model Class?

Apr 9, 2010

so i want to follow the mvc conventions but haven't really got the hang of it. i've got problem understanding the explicit difference between a model and a library class and how they relate to each other.

eg. i want to create classes to add/edit contacts and also adding them to a group. i thought it should be divided into 2 classes: Contact and Group. The first class would create a contact. The other one will add the contact to a group. I thought this dividing would be perfect cause their logic is isolated from each others. Contact doesn't care if Group exists or not. Group doesn't care about how a Contact looks like.

So Contact will have these methods:

$Contact->add($name, $email, $address, $phone) // create an entry in database
$Contact->delete($id) // delete the entry in database
$Contact->edit($id, $name, $email, $address, $phone) // edit the entry in database
And Group:
$Group->createGroup($name) // create a group in database
$Group->delete($id) // delete a group in database
$Group->addContact($groupId, $contactId) // add a contact to a group in database

So these classes apparently work with the database. Does this mean that these are models? Or are they library classes that eg. should be put in SYSTEM/LIBRARIES in CodeIgniter. If it's the latter one, how do a Model in this case looks like using the classes?

And how would a controller look like in this scenario? Would be great if someone could give me the big picture!

View 2 Replies View Related

Utility Class Be A Model Class In A MVC Framework?

Aug 9, 2010

Im designing a MVC framework but I dont know where should I put my utility classes. I read somewhere where it said utility classes are Model Classes. Is this line of thinking correct or are they some separate type of class?

View 3 Replies View Related

Pass A Textfield Value To A Pop Form?

Jun 11, 2010

How to pass a textfield value to a pop form? I need to pass the value so that the drop down box on the form would autopopulate the items related to that value in the textfield. I'm using PHP.

View 3 Replies View Related

Problem With Pressing Enter On One-textfield Form

Jul 17, 2005

I have a mail form, where I would like the users to enter a secret code and
check one checkbox before the form are processed and the values can mailed.
Otherwise stop and display an error. But it won't work. What's wrong with my
nice newbie-code? Here it is:

The form:
<div>
<form method="post" action="process.php">
<p>Name:</p>
<input name="name" type="text" />
<p>Email:</p>
<input name="email" type="text" />
<p>Subject:</p>
<input name="subject" type="text" />
<p>Message:</p>
<textarea name="message" rows="6"></textarea>
<p>Enter secret send-code:</p>
<input name="secret_code" type="text" />
<p>Agree to terms?:</p>
Yes <input name="check[]" type="checkbox" value="yes" />
No <input name="check[]" type="checkbox" value="no" />
<br />
<input type="submit" name="submit" value="Send" /><input type="hidden"
name="do" value="send" /><input type="reset" name="reset" value="Reset" />
</form>
</div>

Here is process.php:

<?php

View 2 Replies View Related

Create A Form Which Have An Input Textfield Used To Filled In The Url's Name?

Dec 19, 2010

i have created a form which have an input textfield used to filled in the url's name. eggoogle). the effect that i want to get is when i put the mouse key hover on the text google. the url display on the tool bar is my site's internal address. [URL]......en click the text google. it will go to the google site.the input textfield is used to fill in some url's name. how to get this in php

View 1 Replies View Related

Collecting Form Data Without Knowing Textfield Names?

Sep 10, 2010

I have a giant form, an order pad for internal employees, that has hundreds of text fields. The names of the text fields are product codes, the values that are returned are quantities.

Example: <input type = 'text' name='ABC123 Product 1' size='3' maxlength='3'>

I need to collect the data from the order pad and generate an email to the office with the order. How do I parse the incoming form to collect the text field name and value?I am guessing this will be done via $HTTP_POST_VARS but do not know how to go out and get only the field names and values where something has been input by the user.

View 2 Replies View Related

Form Textfield Title In Drupal Does Not Accept Special Characters?

Feb 17, 2011

I'm trying to give element of a drupal form using the form_alter hook a title that contains special characters

$form['title'] = array(
'#type' => 'textfield',
'#title' => 'this is my title test',
'#required' => TRUE
);

that gives me a blank output on the form page using the check_plain() function for the title does not affect the output :s ,still blank I though it's an encoding problem but I checked all my enc settings (database,server,theme template) they are all set to utf-8

View 1 Replies View Related

How To Model A Templating Class

Jan 17, 2010

I am writing a basic templating class for my own project. The basic usage is this:

$template = new Template('template_file.php');
$template->assignVariable('pageTitle', 'Home page');
$template->render();
Contents of 'template_file.php':
<?php print $pageTitle; ?>

This is what template class does step by step:

Stores variables in a private array when assignVariable method is called When render method is called, extracts stored variables, includes template file in a ob_start() and ob_end_clean() block. Stores output in a variable with ob_get_contents() and then prints stored output.

I know this is a very simple templating class but works as expected. The question is should I delegate the including the template file to another class? I had this question when I was writing the unit tests for this class. I thought that file system interaction should be encapsulated. What do you think? If you think that it should not, how can I mock including a file in my tests?

Maybe I just pass the contents of the template file to the class like this:

$templateContent = file_get_contents('template_file.php');
$template = new Template($templateContent);

Edit: I decided to encapsulate the input process of template class for the sake of writing better unit tests and encapsulation. But as johannes pointed out, I needed to use eval() for that purpose which seemed not right. Johannes pointed me to the direction of stream wrappers for mocking the including in unit tests. But that inspired a new idea on me. Here is what I am going to do; I will continue to use include() in my template class but this time with stream wrappers. I will pass protocol handler to my template class while initializing it. This way I can create my own stream wrappers for fetching template data from database or using a local variable. Here are the examples:

[Code]...

View 4 Replies View Related

Use Of XML For Model Class And Structuring?

Dec 23, 2009

I am currently working on a little application: The structure follows in some way the MVC pattern. For short it has the basic things, Models, Controllers etc. Now I am sitting here and do not know whether :

The SQL database is only managed by a model through methods the programmer gives him like: "Hey we have name record so we need a getName() method".

The model dynamically creates the whole database and methods, using a XML file, with which even a non-programmer can design a database.

And should the model class check every/a single request whether it is a valid request e.g. getName() won't work on the houses_tbl, and if it is not valid it does not perform the query, and sends back an error message instead?

I have absolutely no idea how to handle my model class, which structure it should follow and how much the programmer should have to put into a new model so it works as he wants it to work.

Major points: perfomance (which way saves the most perfomance) KISS (which way is simple enough, so a second team mate can understand my logic) extendability (can I extend the structure)

View 2 Replies View Related

Codeigniter How To Map A Class Sent To A Model

Jun 2, 2011

I have a SectorModel with this function:

public function update(Sector $sector) {
$this->db->where('sector_id', $sector->getScetor_id());
return $this->db->update(_SECTOR_, $sector);
}

There are times that I’ll change only the name of the Sector object:

$Sector = new Sector();
$Sector->setSector_name = 'test';
$this->SectorModel->update($Sector);
The generated select looks like:

UPDATE realestate_sector SET sector_name = 'teste', sector_description = NULL It will update but will set all other properties to NULL because it was not set on my object. Right now, I have to fill the whole object before sending it. Is there a way to map the Sector class and update only what was sent on the object?

View 2 Replies View Related

Get The Zend_Application's Database Into A Model Class?

Apr 13, 2010

I have a Zend_Framework application, which has a whole bunch of model classes. I need these model classes to be able to access the application's database (naturally).

Currently I've put this in my index.php:
Zend_Registry::set('db',
$application->bootstrap()->getBootstrap()
->getPluginResource('db')->getDbAdapter());

And then $db = Zend_Registry::get('db'); in each of my model classes that require the database.

But this seems like a horrible horrible hack. Am I missing something basic here?

View 4 Replies View Related

Magento - Creating Model In Custom Class?

May 21, 2010

I'm trying to add some custom filter methods to my magento module. I though it would be simple but I can't figure out why it's not working.

My model which extends the catalog/product class contains this:

public function filterProdType($prod_id)
{
$this->addAttributeToFilter('attribute_set_id', $prod_id);
}.............

UPDATE:

I didn't realize error reporting was turned off, after turning it on I get the error:

Fatal error: Call to undefined method Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection::filterProdType()

View 1 Replies View Related

Retrieving Data In Symfony Using The Model Class?

Feb 15, 2011

Let's say I have a model Ecosystem automatically generated with symfony from my schema.yml. At some point in the code, I would like to retrieve records from the table.I know there are some ways to do this with Doctrine/Propel classes, but, is there a way of doing it with directly the model? I've been thinking in something like this:

$ecosystem = new Ecosystem();
$records = $ecosystem->find(...);

By the way, which is the preferred method to do this kind of things?I've been developing with CakePHP and making queries directly with Doctrine doesn't seem natural to me. What if I decide to change to Propel tomorrow?

View 2 Replies View Related

Adding New Field In Model Class Using Yii Framework?

Feb 15, 2011

In table i have column 'description' , which contain description of goods. I want include in CGridView column 'short_description', which will contain first 150 characters.

class Product extends CActiveRecord
{
/**

[code]...

View 2 Replies View Related

Unable To Call Set Or Create From With In A Model Class?

Oct 8, 2010

I'm working in a CakePHP Model class, writing a function that is supposed to perform a whole bunch of manipulations on the model. I'm trying to follow the skinny controller, fat model idea. However, I don't seem to be able to call any of the model's functions from with in my model. Something hasn't been initialized yet, because I get an SQL error when I do:

Warning (512): SQL Error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 [CORE/cake/libs/model/datasources/dbo_source.php, line 681]

Query: SHOW FULL COLUMNS FROM

It looks as if the table name hasn't been set internally somewhere. My model looks like this:

class Search extends AppModel {
var $name='Search';
var $hasMany = 'SearchResult';[code]....

I know everything the Model needs has already been created works find, because calling that exact same sequence of functions works fine from the Model controller. Like so:

function search($query) {
$this->Search->create();
$this->Search->set('query', $query);
$this->Search->save();
}


That works fine. So what gives? What's going on here?

View 1 Replies View Related

PHING To Generate Class Model Out Classes?

Dec 15, 2010

I wants to generate Class Model of all my classes in code base. I wonder if anyone is aware of anything already available to do that. I wants to do similar to this :[URL] I am not sure if is there anything available for PHP to do along with Phing.

View 1 Replies View Related

MVC Authentication - Create A Separate Auth Class (model)?

Jan 5, 2010

I have a social network-esque site with a nice User model that seems to be covering all my bases right now.

I am reworking the code from spaghetti and want to find the best-practice solution for logging in / registering a user. Here are my options (I think):

Create a separate Auth class (model?) that simply searches for a record of a user and returns a new User object if found.Add "login" functionality to the User class that will allow me to log my user in as any User object that I'd like.

Please let me know the cleanest way to go about this, as I am new to good coding practices (admittedly)

View 1 Replies View Related

Zend Framework Calling _partial From A Model Class?

Jun 29, 2011

I can call partial method from a view object. However, I need to call it from a model class (which is standalone). I need to render a xhtml piece (with code) and parse the result and it happens inside a model class.

View 2 Replies View Related

One View For Two Models: Use A Base Model Class To Make It Easier?

May 9, 2011

A website for managing hotels.Another kind of Hotel model has been added over the course of the project, so now they are two.Now the boss wants the list of Hotels to include both kinds of Hotels. was thinking of the following possible solutions:Invent a superclass containing the common properties needed to display in the list of Hotels, and override appropriately.Hack my way in the view. It has one loop now, producing HTML code on the way (obviously). If this works, there will be two loops.The problem I see with approach #1 is this: "Hotel1 extends BaseHotel1", "Hotel2 extends BaseHotel2". So OK, I will create a superclass, then what?The problem with approach #2 is this: I am still far from a "pro" Symfony developer and I am not sure the view in question will have access to more than one model methods at all. Maybe render-partials from another module would workSo, how do I do this? Do you think the problems I listed are easy to solve? Do you see another approachesI

View 2 Replies View Related

Web Form Processing By Means Of A Form Model Description?

Apr 22, 2011

often, I get asked to write a small mini application which basically presents a form and verifies certain values and conditions once submitted to the server. Thus, I started to generalize the process.

Now, the app loads a YAML specification of the form and a generalized controller manages its processing: Presents an instructional welcome page, presents the form, receives and validates values. Finally, it hands over the verified result to the persistence layer and informs the user, that his data/request has been saved.

The YAML based approach could eventual lead to a solution, in which the client writes himself a form model - without knowing a programming language. I wonder, if I reinvent the wheel. Does someone know of a standard solution?

View 1 Replies View Related

[Zend Framework] Fetch Data From Another Table Within A Zend_Db Model Class?

May 16, 2010

I have two tables registries and names.Consequently, I have two model classes.I'm coding a method in registries model and I need to fetch all names in the names table/model.How'd I do it?Should a simple new Names() work?But, is it recommended?

View 2 Replies View Related

Modular Application Zend Framework 1.10 Not See Class In Default Folder Model?

Jul 23, 2010

i have next folder structure zf version 1.10

/application
/config
application.ini
/Forms
/Layouts
/modules
/default

[Code]...

When i in any controller trying $a = new Manufactur() i see Error not find class when i before call use include 'path/to/manufactur.php'all work fine

View 2 Replies View Related

Controllers And Libraries To Work In The Model All Ofthe Database Class In The CI User Guide?

Jul 11, 2011

I have two databases I need to connect to, which I can do in the controllers and libraries I have written.For some odd reason (i'm assuming I'm just missing something simple here)I can't get it to work in the model all of the sudden. I have read the database class in the CI user guide.I tried making a reference to $pew when loading pew($this->pew =& $this->load->database('pew', TRUE)to no avail.

Error
PHP Fatal error: Call to a member function query() on a non-object in
/Sites/CI/nyan/application/models/pewpewmodel.php on line 15
Line 15
$this->pew->query('SELECT * FROM ExtractEvent'); //simplified for testing database.php:
$active_group = 'nyan';
$active_record = TRUE;

[code]...

View 2 Replies View Related

Get Model Class With Magento Retrieve Data Based On A Mysql Field Which Is Not A Primary Key?

May 18, 2011

I would like to change this snippet to fetch some data from a table, and instead of triggering the primary key(which looks like the default behavior of the load() function), I would like to trigger another field in my request...How can i do that ?

$mytable = Mage::getModel('mytable/mytable')->load($mytable_id)->getData();

View 1 Replies View Related

CakePHP - Access He Form Helper's "current" Model As Supplied To $form->create()

Jan 7, 2011

In my CakePHP 1.3 application, I need a form control that is: Comprised of multiple form elements, and Reusable in more than one form. I'd like to avoid code duplication if I can. So, I'm creating an element that outputs my form control, and have hit a roadblock when it comes to populating the control with values on an edit action. Now, when you're using the default field types, CakePHP does this for you, but I need to get information out of $this->data and do it myself in this case. The problem is that $this->data looks like this:

array(
'Model' => array( /* fields from Model */ ),
'AnotherModel' => array( /* fields from AnotherModel */ )
);

Within my reusable element, I don't know what model my field belongs to. However, I told this information to the Form Helper when I called $form->create() (in the view that includes the element I'm writing), so it seems like it should be able to tell me. And indeed, the API documentation for the FormHelper class tells of a defaultModel property, but sadly, this property is empty. Now, the simple solution is to pass the model in as a parameter. I can do that. But, I'd like to avoid parameter bloat where I can, and it seems like this ought to be possible, but I can't figure out how. Is there a way?

View 2 Replies View Related

Model For Default Generated Form?

Jun 13, 2011

i generated new project and new module with Jobeet [URL].....org/jobeet/1_4/Doctrine/en/03 where is the model for this form? i would like show how this is add or edit in database?

View 1 Replies View Related

Create Model With Zf Tool - Zend Framework Automatic Model Generator For Mysql

Jan 29, 2011

I want to create a model with zf tool. But "zf create model xxx" command is just an empty class. What must be a path to .sql file?

View 1 Replies View Related

Magento - Add Relationship Between Order Model And Custom Module Model With Database Constraint?

Dec 18, 2010

I've created a module that has its own table faces. Also, the module setup adds a face_id attribute sales/order to connect them:

$installer = $this;
$installer->startSetup();
$installer->run("
CREATE TABLE `{$this->getTable('faces')}` (
`face_id` int(11) NOT NULL auto_increment,
`title` varchar(255) NOT NULL,
PRIMARY KEY (`face_id`)

[Code]...

Also, I'd like to add constraints. I would add them directly to the CREATE TABLE SQL, but I'm wondering if they are automatically added if I use some sort of built in method for creating this relationship.

View 1 Replies View Related

ZF - Doctrine 2 - Model Classes Or Lightweight Model - Service Layer ?

May 1, 2011

I am integrating Zend Framework and Doctrine 2, and I am discovering the Service layer. Now I understand (am I wrong ?) that I have 2 architectures possible : A model, where classes contain domain logic, i.e. properties + getters/setters + complex methods A lightweight model, where classes contain properties + getters/setters and a Service layer, containing domain logic, and modifying the model classes

What are the pros/cons of each ? It seems weird to me to loose OOP by putting domain logic as external to the model, so I don't understand why use a Service layer.

View 1 Replies View Related

CakePHP: Access Model In Other Model / In App_model.php For Validation Of Banknumber

May 7, 2011

I am wondering how I could use data from a Model B while I am validating Model A, here to check if an entered Banknumber is a correct one: My Users specify their bankaccount during the registration. E.g. the "banknumber". I am validating this the normal way in my user.php model

var $validate = array(
'banknumber' => array(
'minLength' => array(
'rule' => array('minLength', 8),
'message' => '...',
'required' => true,
),

Now I want to know if the entered Banknumber is a real one, so I got a table "Banks" in my DB with all real Banknumbers, and I am using some own validation functions which I specify in app_model.php.

[Code].....

But this is never working, because while I am validating the User-Model, I can only use this one in an app_model - function, accessing it with $this->name or so... a $this->Bank is NOT possible, I get:

[Code].....

Is there ANY way to import/access other models in a function in app_model.php?

View 1 Replies View Related

Populate A Doctrine 2 Model With Form Data?

Sep 19, 2010

Imagine a User model like this:

class User {
/**
* ...some mapping info...
*/
private $username;
/**
* ...some mapping info...
*/
private $password;.........

View 2 Replies View Related

Codeigniter Form Validation To Model Logic?

Jun 23, 2011

I'm working on my first codeigniter application and have encountered some confusion around handling post data.

More specifically, I understand the role of $this->form_validation->set_rules(), and how set_value() works to repopulate input values when the validation failed, but what I can't figure out is if $this->input->post is the same value as the set_value equivalent.

I understand that the majority of validation rules would have a boolean result, however what about ones like trim|htmlspecialchars - these also have the benefit of preparing the data for db queries.

So in my model, can I access the inputs after being processed by the form_validation library, or should I do the additional preparation inside the model directly onto $this->input->post('variable')?

My gut tells me that I should add final processing like htmlspecialchars right before the sql in the model, as it is really a db specific operation (I would not want & instead of & in my form inputs, but I would want & in the database).

Incidentally in my reading I did come across $this->validation->variable which would appear to have been the answer to my question in previous CI versions.

View 2 Replies View Related

Put Form Validation Rules In The Controller Or Model?

Apr 13, 2011

On one hand form validation could be seen as part of the application logic and therefore belonging in the model.On the other hand, it deals directly with the input coming from view and handles displaying errors, etc. From that angle it makes more sense to put it into controllers.Which one is the right approach from the MVC point of view?P.S my form validation actually consists only of writing a list of fields, their rules, and passing it on to a form validation library, which returns true/false on whether it passed validation or not.Example:

$this->load->library('form_validation');
$this->form_validation->set_rules('name', 'Name', 'required');
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');

[code]...

View 3 Replies View Related

Return The Value Of A Variable From Controller To Form Or Model?

Jun 6, 2009

i am new to zend framework. I know that i can return a value of a variable from a form to the controller. Can I also return a value from the controller to any form or any model? If this is possible then please tell me that how can we do it

View 1 Replies View Related

Change Model's Title Without Rename Model/dbtable?

Jun 16, 2010

I have a table that store all information about class, but because Class is reserved for class name I had to rename the table from classes to types.But in the view section I need it to be displayed as "Class", including the Paginator links.Anyway to achieve this by adding something in the Type model, without completely customize Paginator and and all view compoenents?

View 1 Replies View Related

Cakephp: Can Model->find('all') Return Results Without Model Name

Sep 11, 2009

Using Model->find('all') returns an array with the following structure:

array(
0 => array('Model1' => array(/* Model1 fields*/), 'Model2' => array(/* Model2 fields*/), ...),

[code]...

View 2 Replies View Related

Validation In Model/View/Controller Model?

Mar 14, 2011

I am working on a PHP project which makes extensive use of the MVC design pattern. I am looking to add validation to a form and am curious as to what the right place for validation is.Due to the way that forms are generated, validation on postback data is a lot simpler and less repetitive in view components. Is it acceptable to have the view validating response data, or should this be implemented within the controller, or even the model

View 2 Replies View Related

Passing Variables From Model To Model In Codeigniter?

Jun 9, 2010

I need to pass a variable to model, that model needs to send another back and use that variable to query a different model.

EG:

I have a product_ID which I send to the product model, From that I find out the supplier_ID. I want to grab that supplier_ID to the supplier model to get the supplier name.

How do you implement this in codeigniter?

View 5 Replies View Related

Difference Between Model->alias And Model->name In CakePHP?

Jul 30, 2009

'alias' and 'name' are both properties in cake models. They seem to be similar, but since both of them exist, there must be a difference.

View 2 Replies View Related

Should Sub-objects Be Fetched In The Model Or The Model Mapper

Jun 4, 2011

This is a follow-up to my previous question: Should dependent rows be fetched in the Model or the Controller?. Let's say that a Patron can check out Books. If, given a Patron object, where and how should the Books they have checked out be fetched? Here are some possibilities I've considered:

In the Patron Model, add a getBooks method When a Patron is instantiated, automatically get its books and store it as the books property Create a method in the PatronMapper called getBooks that takes a Patron ID

View 1 Replies View Related

Cakephp One Form, Multiple Models, Not Display One Model's Validation Messages?

Jan 12, 2011

I have a registration form and I am creating a record in both User and Identity tables (a user hasMany identities)the form looks like this

<?php echo $this->Form->create('User');?>
<fieldset>
<legend><?php __('Register'); ?></legend>
[code],.....

View 2 Replies View Related

CodeIgniter: Passing Array From Form To Controller Then To Model To Insert Into Database?

Mar 25, 2011

I've got a form in a view. The following row can be duplicated over and over allowing the client to add as many trashcans as they wish:he problem starts when I try to get the array from $invoice_itemIf I have just one line item:

I've tried $invoice_items = $this->input->post('$invoice_item');
but if I do var_dump($invoice_items); to see what I have I get bool(false)
So, I tried: $invoice_items = array($this->input->post('$invoice_item'));

[code]...

View 1 Replies View Related

Mvc - Passing Session Information To The Model Via Functions Versus Allowing Model To Grab An Instance Of The Session Data

Jan 17, 2011

what the php best practices on session information is? should the model request access to the global session variable and then select the information it needs, or should the methods of the model accept the session information as parameters and let the controller handle grabbing the data from the session?

View 1 Replies View Related

Difference Between Model And Model Resource?

Jan 21, 2010

Im starting a project with Magento. Let me first say, that i come from the MS world, i have never used PHP before, and while im catching up quite rapidly i'm def a php newb.I can't quite seem to grasp the differences between the model, resource model, resource and entity objects and how they are related in the magento architecture.I've tried googling for days now and i have found little info, and what i have found doesn't really explain it!

View 1 Replies View Related

ADVERTISEMENT