Saturday 15 May 2010

php - Newly added field does not update unless made mandatory in Yii 1.1 -


Felő Eti-Etiz,

After the model I added a new date field to the DB table and the form The code was generated, the value of this area is not being maintained in DB. However, it works if the model is made in the "required" model class This is a blank space in DB and I do not want it "necessary" in the model category.

(array, 'start_date, court_type, org_id');

In the Model class function rules (check the field enologi_data ):

  'Array', 'maximum' = 'array', 'array', 'array, court_type, org_id, position, no_courts', 'numeric', 'integer only' = & gt; true) & Gt; 45), // The following rule is used by search (). @todo Delete the attributes ('id, location, level, start_date, enroli_date, ref, court- Aip, Org_aidi ',' safety ',' on '= & gt;' looking '),);  

This asset is not in the "required" list.

View _form.php in:

   'enrolby_date', 'attribute' => 'enrolby_date', 'model' = & gt; $ model, 'option' = & Gt; array ('showenim' => gtk 'guna', 'datformat' = & gt; 'yy-mm-dd'),)); ? & Gt; & Lt ;? Php $ echo $ form-> Error ($ model, 'enrolby_date'); ? & Gt; & Lt; / TD & gt; & Lt; / TR & gt;  

Note that I tried to do it without the DatePicker widget, the behavior is similar.

The DB table definition is like this -

  mysql> Travel; + -------------- + ------------- + ------ + ----- + ------- - + ---------------- + + | Field | Type | Faucet Key | Default | Extra | + -------------- + ------------- + ------ + ----- + ------- - + ---------------- + + | ID | Int (11) | No | PRI | Faucet Auto_interpretation | | Location | Varchar (45) | Yes. | Faucet | | Level | Int (2) | Yes. | Faucet | | Start_date | Date | Yes. | Faucet | | Enrollby_date | Date | Yes. | Faucet | | Referee | Varchar (45) | Yes. | Faucet | | Court_type | Int (2) | Yes. | Faucet | | Position | Int (2) | Yes. | Faucet | | Org_id | Int (11) | No | Child | Faucet | | No_courts | | Int (2) | Yes. | Faucet | + -------------- + ------------- + ------ + ----- + ------- - + ---------------- + 10 rows in the set (0.06 seconds)  

Additional information: Show date values ​​in the form Action Update, If I populate the fields in the DB table using a SQL update. There is no problem with field names and bindings because it works fine by making it "necessary".

What's the problem here?

Cheers Prompt

Update: Here is another hint if I add the following line of code to the rule () function So the problem disappears.

The array ('start_date, enrolby_date', 'type', 'type' = 'Gtc:> It seems that the model requires some type of evidence that the field exists.

I think the problem is array ('name' = & gt; 'enrolby_date') . When you create the form, yii creates the input type = "text" name = "model name ['field name'] '& gt; . > Name to change the properties of the field and assign it to name manually, then yi I does not set it automatically I think that you have two solutions, you can change the name in the first: array ('name' = & gt; 'YourModelName [enrolby_date]') Second Solution: You can manually assign "enrolby_date" to the controller:

  $ model-> enrolby_date = $ _POST ['enrolby_date']; < / Code> 

No comments:

Post a Comment