Default value on add form

QuestionsDefault value on add form
Gary Brett asked 6 years ago

Hi Abu, I am trying to set a default value on the add/edit form with no success, any ideas why this wouldn't work?

$col["editoptions"] = array("value"=>'" . userValue(null, "username") . "');

Even if I add static number it doesn't work?

$col["editoptions"] = array("value"=>'100');

I have the form options set as;
$opt["add_options"] = array("recreateForm" => true, "closeAfterEdit"=>true, 'width'=>'620');

SAny ideas at all?

Thank you

4 Answers
Abu Ghufran answered 6 years ago

To set default value, use defaultValue key. Only shown on add dialog.
$col["editoptions"] = array("defaultValue"=>'10');

Gary Brett answered 6 years ago

Great Abu, this works on the edit record but on add new record just pulls through the code, not the value..

$col["editoptions"] = array("defaultValue"=>'" . userValue(null, "username") . "');

When editing it pulls user name through but on new it outputs " . userValue(null, "username") . "

Sorry for the questions I have searched forum and even tried adding $col["addoptions"] = array("defaultValue"=>'" . userValue(null, "username") . "'); to see if it worked..

Thanks you again

Abu Ghufran answered 6 years ago

I am unable to understand what userValue() actually is.

If it is php function, it should be written as:
$col["editoptions"] = array("defaultValue"=> userValue(null, "username") );

The defaultValue sets the value while adding. In editing, it sets the db fetched value of the record.

If it is JS function, and you will have to use afterFormShow event. Let me know the exact scenario.

Gary Brett answered 6 years ago

Thats fixed it, many thanks once more great support Abu.


Your Answer

3 + 18 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.

How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?