In my symfony application I would like to get form model object before calling save method.For example: on form submit I bind it to the related Form Object. And before calling save method I want to get related Model object with its submitted values.I know there is $this->form->getObject() method.When I call it before $this->form->save(); method it returns model without values. Is there any way to get it? Any help is appreciated.
Thanks in advance!
The form's values are only set in the object in save(). You have two options:
if the values are enough, use $form->getValues(), it returns the cleaned array
if they aren't, call $form->updateObject() manually.
Related
I want to set the "standard" TYPO3 field "fe_group" in the extbase controller. As far I see there no "standard" getters and setters? https://typo3.org/api/typo3cms/class_t_y_p_o3_1_1_c_m_s_1_1_extbase_1_1_domain_object_1_1_abstract_entity.html
I tried to implement them in the model, but it does not work - I do not get any error but it is never set.
What exactly I want to do:
I have an object of type \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup and I have an object of my record type (I can set other fields without any problems).
Now I want to do something like:
$myobject->addFe_group($feusergroup);
Do I have to implement this by my own to my model? I tried to implement fe_group as ObjectStorage and also as string - does not work? :-(
Does anyone have a solution for this?
Thank you
Christian
First of all: In models please name functions and properties lowerCamelCase. So a field "fe_group" in TCA would become "feGroup" in the model and the function would be "addFeGroup".
FrontendUserGroup model has a function addSubgroup to add other groups as subobjects. Is this the right thing for your purpose or what you need those relation to another group for?
https://typo3.org/api/typo3cms/class_t_y_p_o3_1_1_c_m_s_1_1_extbase_1_1_domain_1_1_model_1_1_frontend_user_group.html
In glade it is possible to set an unique ID to an object. In the code one can obtain a pointer to this object by searching for it's "glade ID" via gtk_builder_get_object().
However for my current use-case I just want to read out this ID from an GObject. What's the API to do so ?
You can't. The builder ID is stored in the builder internally, not in the GObject.
The reason for this is that IDs must be unique per builder, which would be impossible to enforce if you were able to get and set them via some GObject API.
You could use gtk_widget_get_name() to identify an object.
It is possible using Gtk.Buildable.get_name(object). This method will return the Glade object id.
This snippet will print all object ids in your Glade XML:
builder = Gtk.Builder()
builder.add_from_file("my-window.glade"))
for obj in builder.get_objects():
print(Gtk.Buildable.get_name(obj))
As stated by #ptomato it's seems not possible.
I found that in that line in the documentation:
All the fields in the GObject structure are private to the
implementation and should never be accessed directly.
But you can circumvent it because at one point in your code you were refering to it by the id that you typed in (or the code you wrote type in) so you just need to store it at that point. And link it somehow (with a variable or a data structure) to the name of the variable holding the object.
Is it possible to create a form using form helpers without having an object to link the form to? I want to just design a form and have it render, but I don't have an object to point to yet. Or, is there a simple way to create a dummy object? For instance,
<p>#textField(objectName="dummy", property="name", label="Name")#</p>
objectName seems to be a required parameter. http://cfwheels.org/docs/1-3/function/textfield
In CfWheels, there are four types of form helper functions:
form object functions
form tag functions
Form Association functions
General form functions
The one you are using is form object function which requires object and there are other functions (form tag functions) like bellow that don't require object to bind to:
textFieldTag()
fileFieldTag()
checkBoxTag()
etc....
Check out all [form tag functions][1]
[1]: http://cfwheels.org/docs/1-0/function/category/view-helper category.
I hope this helps.
I am building a JavaScript app, and have been learning JavaScript and Backbone, and have added Backbone-relational to it. It saves to a Django-tastypie REST server.
So before I was using Backbone-relational, I would create a new object, and either set the attributes when it was created, by passing them to the constructor, or passing a dictionary of attributes to the save() method.
e.g in CoffeeScript:
myModel.save {attribute:value , foreignKey_attribute : '/api/resourceUri/'}
success ->
....
Now I have switched to Backbone-relational, it solves a lot of problems fetching the data, but I cant seem to set the foreign key attribute as before.
Either passing the dictionary to the constructor, or the save method. When I look at the object in the console, or the contents of the POST, the foreign_key attribute is always null.
Is there a way around this, or another way of setting the foreign_key_attribute (given that I have the foreign key id)?
Ok, worked it out.
Rather than trying to set the flowcell to a resource_uri string, set it as the flowcell object.
Then in the relations I needed to set the following:
includeInJSON: 'resource_uri'
This serialzes the object the way the tastypie back end expects it.
I am trying to figure out the best way to design something. I am writing an iPhone App and for the most part I am using async calls to a web service. This means that I cam setting up a URLConnection, calling start and letting it call me back when the data is available or an exception occurs. This works well and I think is the correct way to handle things.
For example:
I request a list of people from a web service. The resulting list is Xml Person elements which will be translated into an objective-c "Person" object by my XmlDelegate.
When I call the function to get the person, I pass in a "PersonResultDelegate", which is a protocol with a single function called "PersonReceived:(Person *)p". So, each time I get a complete Person object, I call that method and all is well. So, my detail view (or search result view) just receives the elements as they are available.
The problem comes when I need to obtain more then one specific object. In my specific case, I need to get the first and last appointment for a person. So, I need to make two API calls to obtain these two single Appointment objects. Each Appointment object will result in a call to the registered AppointmentResultDelegate, but how will I know which is the first and which is the last? I also need to somehow handle the case when there is no "first" or "last" Appointments and the Delegate will never get called.
What would be the correct way design wise to handle this? Should I add some additional context information to the initial request which is passed back to the handle in the delegate? An opaque piece of data which only makes sense to the person who made the initial call? What are my other options?
Solution
What I actually ended up doing is just passing an opaque piece of data along with the Appointment to the delegate. So, when I request an appointment object I have a method like:
getNextAppointment withDelegate:self withContext:#"next"
getPrevAppointment withDelegate:self withContext:#"prev"
This way when the delegate gets called I know what appointment is being delivered.
"Each Appointment object will result in a call to the registered AppointmentResultDelegate, but how will I know which is the first and which is the last?"
By looking at the order in which you receive these callbacks. Or by looking at some value in that xml data. Like a sequence or data. I don't know your data of course.