mdomba, echoing it does not render anything. I don’t see anywhere that it could be written over as I am not using any special code yet, just basic CRUD with multi model form functionality. I am lost as how to troubleshoot this though.
Ok by adding die() I can now see it. attribute1 is just a sudoname to post on here. I am using my actual names in my code and yes they do match code/db. Like I said if I just use my form I do not have any problems. Any ideas why my code is not writing it to the db?
Yes it is good to see that it is actually there but not so good it is not writing.
My db field for that attribute is char(1).
Rules in my model for it are ‘required’ and ‘length’, ‘max’=>1
For beforeSave() to exist I have to write it in, correct? Like I said I am just working with basic code at this point. I am using giix (extension) generated code not gii but still do not see any implicit beforeSave() calls written in there either.
And without a beforeSave() function in the mix, and my sequential statements in the controller of defining the attribute and then saving it is confusing me.
Yes I know I am the only one with eyes on the actual app and I do appreciate your suggestions. I come here to ask the question only after I have done everything I know how to in trying to figure out the problem. I am sure I am not the first to hard code attribute values into the controller so of course I wanted to make sure my code is correct.
I have logging turned on and enableParamLogging but the logs are not revealing anything. When I submit the form it only bounces the page and nothing happens. When a form does not work I have yet to see anything returned. Am I missing something here?
I do not know if you are asking something different from what I meant when I said it works just fine if I assign that attribute through the form itself. Also manual SQL works just fine.
Just to try something different I kept that line of code in the controller and sent an invalid value through the form. Well the record was created and the value of the attribute was that which is defined in the controller and not what I entered in the form. Of course when I remove that statement in the controller and input that same invalid value in the form I then get a SQL error.
Therefore that value as defined in the controller is only accepted when some value is passed by the form.
This table only includes that attribute and an auto_increment ID so I removed any reference to $model (i.e. errorSummary in _form and ‘model’ => $model, in renderPartial of create) since the only assigned attribute would come from the controller, but that did not seem to have any affect on it.
I really did not understand all this “with form/without form” thing… and I’m a bit out of ideas… and you did not answer some questions… so I’m not sure you did try them…
Did you validate the model somewhere as by using save(false) you are not validating it… why don’t you use save() so that the validation is done… and than you can check if there are some validation error…
And did you check the result of save()… did you get true or false?
if(save()) // <- without false, so that the validation is done
echo "not saved";
Not sure if I am doing something wrong but taking your advice above I can not get any message to be rendered (i.e. saved / not saved). When I mention using a form or no form I am actually talking about using the generated gii content in the views of create.php and _form.php
Yes I also put that in there. I really do appreciate your help here.
Although I can not send code from this app directly I can recreate the problem in another file and post that on here with the schema if you can throw it into a test app so hopefully you can directly see what I am seeing. Let me know if you want me to put that together.