2
1
0

Hi

Hoping to find some instruction around creating widgets. What I want to achieve is a widget that when dragged onto the form will allow me to check a box to place other custom blocks on the form.


For example we want a user to be able to drag this widget onto the form and for them to select the type of form it is going to be like payment or non-payment, gst or non gst and then place the appropriate corresponding widgets in the form. Just need some instruction with editing the xml.

Thanks
Don

    CommentAdd your comment...

    1 answer

    1.  
      3
      2
      1

      Hi Don, when you say,

      and then place the appropriate corresponding widgets in the form

      do you mean:

      1. Automatically place addition widgets in the form in different locations? Or;
      2. Place them inside the newly added widget/block, but only if they're required.

      If you mean option 1, this is not possible. If you mean option 2, it is possible and I will update my answer to provide you with an example.

      EDIT: (Apologies for the delay)

      You can add custom checkbox properties to a widget/block with the following line of XML (added to the Blocks XML Source) or by editing the properties in the Property Definition tab of the Custom Type Editor (go to the custom types tab of your organisation and click edit on the block/widget).

      <property name="property.internal.name" category="Custom" createpattern="" label="Property Display Name" type="boolean" visibility="normal" value="true"/>

      In this XML, the attributes are:

      name - this is the internal name of the property (similar to the internal name of a widget in a form).

      category - this is the tab the property will be added to in the Property Editor for this widget.

      createpattern - this property specifies whether the property should be requested when the widget is first added to a form. The valid values are "%null%" (null, don't request), "" (blank, request), or "*" (asterisk, request and mandatory).

      label - the display text for the properties label in the Property Editor

      type - the property data type, e.g. boolean, string, etc.

      visibility - when the property is displayed, valid values are "normal" (always display in Property Editor), "advanced" (only display when in advanced mode, i.e. when clicking the cog icon), "hidden" (never display in the Property Editor.

      value - the default value for the property (for booleans this is either "true" or "false")

       

      Once a boolean property has been added, child widgets inside the custom block can have properties added to them that will control whether they are rendered. The properties look like this:

       

      arg1="${property.name}" if="True"

      This says "If the value of the property with an internal name of "property.name" is true, then render this widget, otherwise exclude it.

      This is similar to a visibility rule, except with visibility rules the widget is always included in the form, then hidden later. These properties will completely prevent the widget from ever being included in the form's HTML.

       

      Putting it all together you might end up with a block defined like this:

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <module name="Block-Custom-Example" category="Custom" description="" editable="true" embeddable="true" extends="Block-Standard" label="Example Block">
          <property name="include.text.field" category="Custom" createpattern="" label="Include Text Field" type="boolean" visibility="normal" value="true"/>
          <content>
          	<!-- this field is only included if the 'include.text.field' property has a value of "true" -->
              <field name="MyTxtField" styles="styleset.size.fill" type="Field-TextField" arg1="${include.text.field}" if="True">
                  <setproperty name="label" value="My Text Field"/>
                  <setproperty name="data.max.length" value="50"/>
              </field>
          </content>
      </module>
      1. Don Sibley

        HI Jye, Yeah option 2 should be fine if that's all that's possible. Looking forward to see how this is done! Thanks

      CommentAdd your comment...