golfads VIP
Total posts: 216
27 Март 2014 22:55

Hi,

I am having a small trouble here, I am using Breezingforms to create some forms that I want to use within Cobalt so that users and visitors can submit inquiry through this form in Cobalt records.

However, I do not want users to be able to view/edit the fields where I will input the breezingforms code, the best solution is to create an html field, add the form code (e.g. {breezinforms form_2} ) so that this code is transformed into a form on frontend.

So, I search a way to make this field either read only or hidden on the record submission page but could not find it, can you please guide me through this?

Please note that only one form will be used per type/section in Cobalt, therefore just need to find a way to add the code {breezinforms form_2} in a field and block frontend users to edit this field and also that this field is also able to transform code like this with Joomla breezingforms content plugin.

Thanks,

Tomy

Последние изменения: 31 Март 2014


pepperstreet VIP
Total posts: 3,837
28 Март 2014 01:41

(Do you really need BreezingForms for it?)

A.) Should be possible with custom field INPUT template. Give respective form field a "readonly" and "hidden" attribute. Not sure about the exact code in HTML field... but you could also use textarea or even text-field. The latter might need a prepare-content in output template!

B.) Also possible to unset the respective field(ID) in the default submission form template.

@Sergey Regarding B) I remember there was a form template parameter in ME Resources, where you could hide/exclude certain fields from display. Would like to see this again.


Sergey
Total posts: 13,748
28 Март 2014 05:24

Here is how i would do it.

  1. I would use either text or select fields. If select, then I use SQL as source to list all forms in BreezingForms.
  2. Now when form ID is saved, in custom field output template, I would use this value to display form.

But if you have only one form everywhere and you do not need to select different form for every article, you may use custom article template directly.

In any way when you have your ID you may use this code

$text = '{breezinforms form_2}';
$text = JHtml::_('content.prepare', $text);
echo $text;

golfads VIP
Total posts: 216
28 Март 2014 09:03

Hi,

Thanks for all these information, will try to get a solution out of these and let you know soon, thanks again.

Tomy


golfads VIP
Total posts: 216
29 Март 2014 09:33

Hi Sergey,

I would better like to use the select option and get form from SQL, however, I am not that friendly with SQL, making some search in the database, I could get this:

SELECT * FROM `ze308_facileforms_forms` WHERE 1

However, I do not know what should I need to add additionally to get the form, adding only the code below gives me a select box with blank selection list, see below:

select_box_form

Can you please help me to get this to work properly so that I can retrieve form from SQL using the select field and show the selected form on frontend? This will help me very much.

Thanks,

Tomy


pepperstreet VIP
Total posts: 3,837
30 Март 2014 03:44

Here are two examples for getting only published forms.

Select shows all forms by "Name/s"

SELECT `id` AS id, `name` AS text
FROM `#__facileforms_forms`
WHERE `published` = 1

frontend result:

mj_cobalt_select_custom_sql_forms

Another variant with "Title"

SELECT `id` AS id, `title` AS text
FROM `#__facileforms_forms`
WHERE `published` = 1

There is also a column "package", which could be used for WHERE to filter the list down to a certain group of forms... if you have a lot of forms, or if you want to exclude the demo stuff.

@Sergey
BTW, i had no luck to change the first Select parameter? The text should be "- Select a Form -", but it keeps the default value? A bug?


golfads VIP
Total posts: 216
30 Март 2014 08:25

Hi,

Thanks @pepperstreet now I got the forms showing clearly in the select box:

form_select_list

However, now, maybe I miss something and that there is some else that needs to be done in Cobalt, when a select a form from the list, it does not show on the record page on frontend, should I still need to add some info in the custom field output template so that the forms appears? If so, I am showing records through 'Tab' and I would like the form to show up under a specific tab, in this case, under the 'Inquiry' tab as shown on this page Click here to link...


pepperstreet VIP
Total posts: 3,837
30 Март 2014 23:27

golfads I still need to add some info in the custom field output template so that the forms appears?

Yes, you have to send the result of your selection + the BF plugin syntax through Joomla Content Prepare function...

BTW, you have to make sure to use the BF form "name". As far as the J!3 Content plugin version is concerned, there is no option to use "ID" or "Title". The name is required. Hence the correct UPPERlower cases for the plugin Syntax and FormName!

  • Create a new field Output template e.g.: bf-prepared.php
  • Select this template in your Select field params:

Bildschirmfoto 2014-03-31 um 01.25.24

  • replace the default markup...
<?php echo implode(', ', $this->values); ?>

with...

<?php
$mybf = JHtml::_('content.prepare', '{BreezingForms : '.implode(', ', $this->values).'}');
echo $mybf;
?>

pepperstreet VIP
Total posts: 3,837
31 Март 2014 02:05

pepperstreet BTW, you have to make sure to use the BF form "name". As far as the J!3 Content plugin version is concerned, there is no option to use "ID" or "Title". The name is required.

BTW, who is going to see and use the Form-Selectbox? If you need to show the more readable "Title with Spaces", you would have to add a little bit more PHP... sorry, I forgot about that in my previous comment.

a.) Use Title (incl. spaces), and use exactly the same "Name" but without spaces. If this is the case, you just have to strip-off the "spaces" from the value with PHP... and then output the correct transformed "name".

Additional thoughts:

b.) Input template. Only needed, if the "name" has to be modified before Save. Not necessary in your case.

Since you have to adjust the output value for the BF plugin syntax anyway... you should keep this work in 1 output template.

You might even use form titles plus IDs, custom numbering, A-Z or whatever suits your needs i.e.:

  1. My First Form Title
  2. Your Second numbered Form
  3. The third Form Title

Then you would have to remove the first 2 characters... or any other unwanted stuff in the Title. Again, strip-off spaces... output value etc.


Sergey
Total posts: 13,748
31 Март 2014 06:15

pepperstreet BTW, i had no luck to change the first Select parameter? The text should be "- Select a Form -", but it keeps the default value? A bug?

Doble parameter. There is another select parameter that is used. You can change that one.But in next version fixed.

The rest, couldn't be explained betetr!


golfads VIP
Total posts: 216
31 Март 2014 07:41

Hi @pepperstreet

Thank you very much for these detailed information and procedures, following these guidelines, I was able to proceed further with this but form is still not appearing on frontend. On the website that we are implementing this feature, only website admins are able to add/edit records, therefore site admins will see the select box and add form to their corresponding records.

First step, about the SQL query to get the BreezingForms name:

select_box_with_name

As you can see, we have changed the (SELECT id AS id, title AS text) to (SELECT id AS id, name AS text) so that instead of title, name are selected on the select box.

In the folder com_cobalt/fields/select/tmpl/output we have created a new .php file, named it as bf-prepared.php and added the following codes in the php file:

<?php

/**

 * Cobalt by MintJoomla

 * a component for Joomla! 1.7 - 2.5 CMS ( http://www.joomla.org )

 * Author Website:  http://www.mintjoomla.com/ 

 * @copyright Copyright (C) 2012 MintJoomla ( http://www.mintjoomla.com ). All rights reserved.

 * @license GNU/GPL  http://www.gnu.org/copyleft/gpl.html 

 */

defined('_JEXEC') or die();

?>

<?php
$mybf = JHtml::_('content.prepare', '{BreezingForms : '.implode(', ', $this->values).'}');
echo $mybf;
?>

However, forms is still not showing on frontend, have we missed something somewhere or is there any problem with the codes please?


golfads VIP
Total posts: 216
31 Март 2014 07:43

Forgot to mention, we have also selected the bf-prepared.php in select field parameters:

select_box_parameters


Sergey
Total posts: 13,748
31 Март 2014 08:36

I think you need SELECT title AS id, name AS text. Because $this->value will contain id with is alias of title.


golfads VIP
Total posts: 216
31 Март 2014 08:57

:-( Still no chance, no form appears!


pepperstreet VIP
Total posts: 3,837
31 Март 2014 14:03

golfads (SELECT id AS id, name AS text) so that instead of title, name are selected on the select box.> golfads However, forms is still not showing on frontend, have we missed something somewhere

My forms are displayed. Working with the mentioned SQL and output template. (Stating the obvious... but did you publish the BF Content Plugin ;-) )


Sergey
Total posts: 13,748
31 Март 2014 15:11

pepperstreet My forms are displayed.

But how? You have id as id but you have to have title as id because title is used in {breazingform:[title]}


pepperstreet VIP
Total posts: 3,837
31 Март 2014 15:40

Sergey but you have to have title as id because title is used in {breazingform:[title]}

Plugin Syntax has to be like this:

{BreezingForms : MyBreezingFormName}

The ID is of no use/not for output. It just takes the breezingform "name" column as TEXT. And TEXT is the value, that seems to be displayed in Selectbox... and this TEXT is the value that is stored by the field.

It works.


golfads VIP
Total posts: 216
31 Март 2014 16:15

pepperstreet (Stating the obvious... but did you publish the BF Content Plugin ;-) )

Yes, it is enabled as I am already using forms in other Joomla default content pages.


pepperstreet VIP
Total posts: 3,837
31 Март 2014 16:34

Even with Title AND Spaces it works for me. The following example and output code assumes you are using the same Name and Title for the forms! Only added spaces/blanks for better readability in Selectbox.

Title and Name have to be equal. Just add spaces in Title.
bf_form_title_and_name

Titles displayed in Cobalt Form submission selectbox.
form_selection

BF form displayed in frontend full item view.
result

output template, if you want to work with BF titles and spaces:

<?php
$mybf = implode(', ', $this->values);
$mybf = str_replace(' ', '', $mybf);
$mybf = JHtml::_('content.prepare', '{BreezingForms : '.$mybf.'}');
echo $mybf;
?>

pepperstreet VIP
Total posts: 3,837
31 Март 2014 16:38

golfads Yes, it is enabled as I am already using forms in other Joomla default content pages.

Do you have any output at all? Do you see the plain BF content plugin syntax? Or nothing? Did you check the source (HTML) output?


golfads VIP
Total posts: 216
31 Март 2014 17:32

I should be called a complete idiot!!! There was no error at all, all that you explained were exactly correct, the error was mine, a complete idiot, I simply forget to enable the field to show in the full view, that is why it was not showing.

The solution provided by pepperstreet works perfectly, see the form below:

form_available

Работает на Cobalt