Answer the question
In order to leave comments, you need to log in
How to get value from pivot table (MANY_MANY) in ActiveRecord Yii model?
The situation is this, there are 2 tables, they are treated as MANY_MANY, but in the intermediate table there are 3 more fields (value) (For example, as here http://www.yiiframework.com/tutorial/image?type=gu... but in the table tbl_post_category there is also a value field)
The problem is that if 2 AR models are related as MANY_MANY, then when receiving data from related tables, this field does not appear in the output (find, findAll, etc.).
Now it works like this:
Let's say there are 2 AR models Posts and Fields, in the adjacent table (posts_fields) the post_id|field_id|value field
in the Posts model made a getter
private $fields;
public function getFields() {
//... вытаскиваем из базы необходимые поля
$this->fields = $result;
return $this->fields;
}
Answer the question
In order to leave comments, you need to log in
Maybe I'm wrong somewhere. But it seems there should be no problem if MANY_MANY is interpreted as BELONGS_TO + HAS_MANY to get. Well, for eager loading, use the together=>true parameter.
You do not understand what "event delegation" is, which is why you do not understand why, for example, click can be delegated, but submit cannot.
Fill in the gaps.
You need to read how exactly the on method sets events.
I doubt that the submit event will fire on anything other than the form, although the specification says that it pops up.
www.w3schools.com/jsref/event_onsubmit.asp
Try to handle submit on the form itself. If it works, then most likely the problem is either in the scope (it is impossible to find the specified selector in the document), or in the fact that the event inside the form is not an event on document and, accordingly, is not processed.
Wrapping the script in $(document).ready() doesn't help? Your example works for me.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question