Default value when add row.

QuestionsDefault value when add row.
Sebastián Esteller asked 11 years ago

Hello,
Is possible set default value when insert a new row. I used $col['editoptions'] and works but i need only set default value when add, when edit i want in cell value of database.

Thanks!

3 Answers
Abu Ghufran answered 11 years ago

You need to set defaultValue property for that. e.g.

$col["editoptions"] = array("size"=>20, "defaultValue"=>'10')

Ananda Theerthan answered 8 years ago

Hi Abu,
I do not want this field to be shown in add form. Just add default value when inserting into DB.For ex, I would like to default to current user id .

Abu Ghufran answered 8 years ago

You can connect on_insert event and set value after insert post.

$e["on_insert"] = array("add_client", null, true);
$grid->set_events($e);

function add_client(&$data)
{
$data["params"]["user_id"] = $_SESSION["user_id"];
}

No need to set or show this value on form then.

Your Answer

5 + 6 =

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?