1

I am using symfony 2.3.2.

I have two fields "created" and "active" in my entity but i am not showing these fields to user interface ("new.html.twig").

In createAction method how can i assign values for these two fields in request object manually?

I tried using both ways

$request->attributes->set("active", "1");
$this->getRequest()->request->set('active', "1");

as suggested at Add request parameter to request and Add Parameter to symfony2 Request deep array but it is not working and i am getting below error:-

An exception occurred while executing 'INSERT INTO users (username, firstname, lastname, email, password, active, created, modified) VALUES (?, ?, ?, ?, ?, ?, ?, ?)' with params ["neeraj", "neeraj", "kumar", "[email protected]", "P@ssw0rd", null, null, null]:
2
  • These fields are static or generated? Commented Jul 26, 2013 at 10:36
  • These field are available in Database but i am not displaying them in user interface and want to pass values for those field manually from the controller Commented Jul 26, 2013 at 10:39

1 Answer 1

1

In your situation i would use prePersist or preUpdate callbacks to set current date, look at symfony documentation

Sign up to request clarification or add additional context in comments.

1 Comment

I want to assign current date time to field "created", so definitely i will have to pass this value to request object under createAction

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.