#1 2013-05-01 17:29:21

franky3458
Member
Registered: 2013-05-01
Posts: 2

Checkbox in mailview - Tag missing error

I've got some checkboxes within my form and want to insert them into the mail view to me/the user.
But I only get

Tag missing: fieldname, scope: data.

… for <ion:data:field name />

Unfortunately the documentation seems to be lacking some important notes about forms. Anyway, how can i fix that?


<input name="fieldname[]" type="checkbox" value="val1" id="t1"/><label for="t1">Field A</label> <br />
<input name="fieldname[]" type="checkbox" value="val2" id="t2"/><label for="t2">Field B</label> <br />

Thanks!

Offline

#2 2013-05-02 12:08:01

GWR
Member
Registered: 2013-02-25
Posts: 125

Re: Checkbox in mailview - Tag missing error

documentation about forms
-> <ion:form:my_form:field />

If you are using views to display the form, the view has to get the data provided somehow.

In the example of the documentation, the view is loaded by TagManager_Email->send_form_emails()
(application/libraries/Tagmanager/Email.php)
If you have a look at that function:

...
		// Set the 'data' tag from the received data array
		self::$context->define_tag('data', array(__CLASS__, 'tag_expand'));

		foreach($data as $key=>$value)
			if ( ! is_array($value) && ! is_object($value))
				self::$context->define_tag('data:'.$key, array(__CLASS__, 'tag_simple_value'));
...

				// Set the "data tag" array of data.
				$tag->set('data', $data);

This Tag is first defined to exist and contain "subelements"
Afterwards for each subelement additional tags are defined which just return the value (that's why "simple_value").

In a later stage the tag is filled with data (the $tag->set...).

Afterwards, the view can use the <ion:data:...>-tag to access that fields.

Instead of this approach you could try to use the first one I mentioned (access the form itself) or simulate the approach above - which is only useful if you want to limit the accessible data (MVC-pattern...).

bye
Ron

Offline

#3 2013-05-13 20:42:45

franky3458
Member
Registered: 2013-05-01
Posts: 2

Re: Checkbox in mailview - Tag missing error

I am sorry for my late reply and thanks for your help! I think I missed the mail.

I tried to follow your suggestion, but it is pretty tough to get my form. At the last I made three different checkboxes – each with its own name. That way I can't check if anything is selected, but it works :-)

Thanks again for your help!

Offline

#4 2016-06-22 02:47:27

fredericomarinho.com
Member
From: Juiz de Fora / Brazil
Registered: 2015-06-08
Posts: 40
Website

Re: Checkbox in mailview - Tag missing error

Hello franky!

I was with the same problem here, I need to know what options my clients had checked, and it could be more than one, but at least one.

My solution was get all checked options and implode into the same string.

I edited the file application/libraries/Tagmanager/Email.php. Find this code:

		foreach($data as $key=>$value)
			if ( ! is_array($value) && ! is_object($value))
				self::$context->define_tag('data:'.$key, array(__CLASS__, 'tag_simple_value'));

and change to this:

foreach($data as $key=>$value){
	if ( ! is_array($value) && ! is_object($value))
		self::$context->define_tag('data:'.$key, array(__CLASS__, 'tag_simple_value'));
	else if ( is_array($value)){
		$data[$key] = implode(', ', $value);
		self::$context->define_tag('data:'.$key, array(__CLASS__, 'tag_simple_value'));
	}
}

Just that!
So, if there is "Option1" and "Option5" checked, the email will send both splited by a comma -> Option1, Option5

Worked just fine for me! Hope it helps you!


Frederico Marinho - Social Media and Web Developer
contato@fredericomarinho.com
fredericomarinho.com

Offline

What's Ionize ?

Ionize is an Open Source Content Management System created by webdesigners for webdesigners.

Created and maintained by Partikule and Toopixel, Ionize wants to be the easiest and most powerful CMS.

Can I help ?

Because talent is nothing without involvement, we are looking for motivated coders and webdesigners to join the project team.

Resources

Website : ionizecms.com
Documentation : doc.ionizecms.com

Development : Ionize on GitHub
Translations : Ionize Translations