Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

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

  • giori
  • giori's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 73
  • Thank you received: 14
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!

Please Log in or Create an account to join the conversation.

Last edit: by admin.

Form default values 19 Dec 2011 20:53 #747

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
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

Please Log in or Create an account to join the conversation.

Last edit: by admin.

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

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
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))

Please Log in or Create an account to join the conversation.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
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

Please Log in or Create an account to join the conversation.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
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 following user(s) said Thank You: twev, giori

Please Log in or Create an account to join the conversation.

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

  • giori
  • giori's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 73
  • Thank you received: 14
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.

Please Log in or Create an account to join the conversation.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
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 following user(s) said Thank You: giori

Please Log in or Create an account to join the conversation.

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

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
You are the sunshine of my lifeeeee :lol: :whistle:
The following user(s) said Thank You: iconvisual

Please Log in or Create an account to join the conversation.

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

  • iconvisual
  • iconvisual's Avatar
  • Offline
  • Senior Member
  • Senior Member
  • Keen Joomla! 1.7 Developer
  • Posts: 53
  • Thank you received: 5
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.

Please Log in or Create an account to join the conversation.

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

  • BTB300
  • BTB300's Avatar
  • Away
  • Moderator
  • Moderator
  • Posts: 415
  • Thank you received: 132
Brilliant! THANKS

Please Log in or Create an account to join the conversation.

Last edit: by BTB300.
  • Page:
  • 1
Time to create page: 0.078 seconds
In the begining i would like to say that j-cook is absolutly fantastic tool! And the person who created it is a genius.
Czyżak (Forum)  

Get Started