Accessing Form Content to Place in a div

2 views
Skip to first unread message

Amanda

unread,
Aug 5, 2011, 11:11:07 AM8/5/11
to Reason Discussion
Hi All,

I am working on creating a poll and would like to be able to create
the form in the Reason backend, but then place it into a div located
in our sidebar (using the entity selector). I am currently having
issues accessing the actual displayed content for the form to place in
the div and am wondering if you might be able to point me in the right
direction.

Thanks!
Amanda

Nathan White

unread,
Aug 5, 2011, 12:05:58 PM8/5/11
to reason-d...@googlegroups.com
Hi Amanda - 

I think I may need more information to figure out what you are trying to do, but maybe this will help.

Actual form entities in Reason contain an XML description of a form, and various other options and settings for that form. The "form" module in Reason uses a number of other classes and utilities to implement form display, editing, e-mailing, and saving capabilities. The translation of the form XML into a disco form is done using a class called ThorCore.

If you are writing some custom module and only care about getting the HTML representation of a particular form entity, you can do something like this:

<?php
include_once( 'reason_header.php' );
include_once( THOR_INC . 'thor.php );
include_once( DISCO_INC . 'disco.php );

$form = ... // this is our form entity, obtained however you want.
$xml = $form->get_value('thor_content');

$disco = new disco(); // a blank disco form
$thor_core = new ThorCore();
$thor_core->set_thor_xml($xml);

$thor_core->append_thor_element_to_form($disco); // thor will add the elements described in the XML to the form.

$disco->run(); // this should output the form.

Note however, that many features of forms that you are used to are implemented in the reason form module. Depending upon what you are trying to do, maybe one or both of the following is what need to look at:

1. If you want a form module running in the sidebar instead of main content area you should create a custom page type which runs the form module in a different region.
2. If you want all the features of the basic form module, but need to add functionality on top of that, you may need to write a custom form view that provides some customization on top of the standard Reason form module.

Nate


--
You received this message because you are subscribed to the Google Groups "Reason Discussion" group.
To post to this group, send email to reason-d...@googlegroups.com.
To unsubscribe from this group, send email to reason-discuss...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/reason-discussion?hl=en.


Matt Ryan

unread,
Aug 7, 2011, 11:29:30 PM8/7/11
to reason-d...@googlegroups.com
To clarify how you'd go about Nate's suggestion #1:

If you just want to change the placement of the form, here's how to do it:

1. create a page type like this and add it to the $page_types_local
array in minisite_templates/page_types_local.php:

'form_sidebar' => array(
'sidebar' => 'form',
),

2. Asign the page the form_sidebar page type.

Matt

Reply all
Reply to author
Forward
0 new messages