Welcome, Guest
Username: Password: Remember me

TOPIC: [ADDED] Form default values

[ADDED] Form default values 19 Dec 2011 15:23 #743

  • giori
  • giori's Avatar
  • Offline
  • Senior Member
  • Posts: 73
  • Thank you received: 14
  • Karma: 6
Hello,

Default values defined in a table are not being displayed using a form and "New". The fields are displayed empty. This is for string, text and integer values!
Last Edit: 21 Dec 2011 19:50 by admin.
The administrator has disabled public write access.

Form default values 19 Dec 2011 20:53 #747

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
The default value is not for prefilling the forms.

It acts in model, not in templates.
It is a table field fallback value which is used for every access of the table, wherever in the component. A table security if the null value is not allowed.

If the field is empty on submit, the default value take place.
If the field is not instancied in form, it works.
If you call your model by yourself (custom code), it works too !!!


DEVELOP :
In your view.html.php file, after the getData() call, check if $my_object->id = 0 (NEW) and fill the object with the value of your choice. (2 lines)

But it can be a nice idea, and it have already been asked if I remember.

Took note.
Coding is now a piece of cake
Last Edit: 19 Dec 2011 23:35 by admin.
The administrator has disabled public write access.

Re: Form default values 25 Feb 2012 16:07 #1446

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
  • Karma: 30
I would find it sooooooooo logical that what i fill in default value gets really as default value in form ;-) Could you do that my dear Jocelyn ? Thxxx (i'm so happy today because your cook is sooo great, i really do amazing stuff with it, hope i can show you at joomladays, just to show you how powerful your tool is (i know you know it's powerful))
The administrator has disabled public write access.

Re: Form default values 27 Feb 2012 13:40 #1466

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Ok, Let's see that...

The idea was much more about security 'fallback' value if form value is empty.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: Form default values 27 Feb 2012 15:11 #1467

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Added for you.


There is a checkbox under the default value param.
"Prefills forms" => Use the default value fallback as field initialization.
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: twev, giori

Re: Form default values 27 Feb 2012 16:25 #1469

  • giori
  • giori's Avatar
  • Offline
  • Senior Member
  • Posts: 73
  • Thank you received: 14
  • Karma: 6
Thank you sooo much for this looooong awaited feature. This is one of those basic features that one would expect right away from such a tool or any kind of forms generator.

Just wondering? Although I have some skills in database design, I am far away of being a db design expert, but so far I have never seen this distinction between a separate fallback value and a prefill form value. Either a field is empty or it has some initial default value which will pop up in the form. Having an invisible default value in a field is in my opinion not a good practice. But probably there are reasons I do not see.
The administrator has disabled public write access.

Re: Form default values 27 Feb 2012 16:37 #1470

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
For example a default string value can be anoying in the form if you have to clear it everytime before writing a value in.

Fallback value is for the physical database parameter of the data field. Written in the SQL structure of your table.
And if for any reason, you want to be able to overrhide this default (for example, depending language, fk, access, or else...),
then you have a last chance to insert a piece of PHP before treating the SQL physical default. (in the check() method in mytable.php)

Well, maybe not so usefull, but it don't require much more source code. Just opening a last php fallback if you want.

That's all.
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: giori

Re: [ADDED] Form default values 28 Feb 2012 09:18 #1472

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
  • Karma: 30
You are the sunshine of my lifeeeee :lol: :whistle:
The administrator has disabled public write access.
The following user(s) said Thank You: iconvisual

Re: [ADDED] Form default values 29 Feb 2012 06:33 #1481

  • iconvisual
  • iconvisual's Avatar
  • Offline
  • Senior Member
  • Keen Joomla! 1.7 Developer
  • Posts: 53
  • Thank you received: 5
  • Karma: 1
Thank you added - but please don't give up your day job LOL. (reference to singing)

Edward
Keen Joomla! and PHP/MySQL developer. Excited about J-Cook.
The administrator has disabled public write access.

Re: [ADDED] Form default values 29 Feb 2012 13:39 #1482

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 415
  • Thank you received: 132
  • Karma: 47
Brilliant! THANKS
Last Edit: 29 Feb 2012 13:39 by BTB300.
The administrator has disabled public write access.
Time to create page: 0.133 seconds

Get Started