iwyg / apipage

API Frontend Page
7 stars 7 forks source link

Arrays #3

Closed zooshme closed 11 years ago

zooshme commented 11 years ago

Thanks for this extension. Saves me a lot of work.

I was wondering is there a way to output json arrays?

iwyg commented 11 years ago

like this?

<data>
  <parent>
    <child>foo</child>
    <child>bar</child>
  </parent>
</data>

will output:

{"data":{"parent":{"child":["foo","bar"]}}}
zooshme commented 11 years ago

Cool. Thanks

zooshme commented 11 years ago

I'm trying to get the results from submitting to an event attached to an api page but the event's results is always empty. Is it because events cannot be attached to API Pages?

Should I open a new issue?

iwyg commented 11 years ago

this should actually work as expected

zooshme commented 11 years ago

Ok. I may be doing something wrong then. I'll have a closer look.

iwyg commented 11 years ago

just did a quick check. It works as expected.

zooshme commented 11 years ago

I've realised what I am doing wrong. I'm not sending the action[name-of-event] as part of the serialized data to the API Page. Do you know how could I do that?

iwyg commented 11 years ago

are you trying to redirect the action from a form submission to the api-page?

zooshme commented 11 years ago

yes

iwyg commented 11 years ago

if it's so, make sure the event is only attached to the api-page and not to the page that holds the submitting form

iwyg commented 11 years ago

but that's not related to this extension. Apipage doesn't intercept logic. It just hooks into the very last moment before symphony is printing out the rendered page content.

zooshme commented 11 years ago

You're right for some reason the serialized data does not contain the action[event-name] = Submit key-value pair.

zooshme commented 11 years ago

I've included a hidden field with the name action[event-name] and value Submit. This seems to work.

iwyg commented 11 years ago

wouldn't it be a more common approach to intercept the form submission and start an ajax post request instead? Just wondering

zooshme commented 11 years ago

That's what I'm doing but I don't know why when I serialize the form the action[event-name] does not get included. Probably because it's on a submit input type

iwyg commented 11 years ago

jquery, right? serialize doesn't include submit buttons

zooshme commented 11 years ago

yup. jquery.

zooshme commented 11 years ago

Thank you so much for your help Thomas.

iwyg commented 11 years ago

you're welcome