Git Product home page Git Product logo

Comments (10)

gwugodevco avatar gwugodevco commented on July 22, 2024 1

use:

{% component 'forms::form1' %}

create the file under your theme: your-theme/partials/forms/form1.htm

it's not required to create that under your-theme directory, but it's more convenient because you can create directory with CMS partials feature.

from october-plugin-forms.

skydiver avatar skydiver commented on July 22, 2024

Hello @Zmove

After looking on October documentation and investigating the source, i can't find a way to rename default components html.

Do you know any alternative or a plugin doing this?

Thanks.-

from october-plugin-forms.

 avatar commented on July 22, 2024

@skydiver

I don't know any plugins to do that (maybe it's not possible cause hardcoded in october core) but I made some progress.

I could customize the path and name of partial file for my form by using partials instead of components.

Instead of doing (lets assume my form have the contact alias)

{% component contact %}

I do

{% partial 'forms/contact.htm' __SELF__ = 'contact' %}

In my form.contact.htm partial, I have the same code than the genericForm/default.htm

I could remove the SELF = 'contact' variable defined in my partial and replace all the {{ SELF }} twig variables in the partial by {{ contact }} but I prefer to keep the default code in the partial (but that's just a personal preference).

I encountered 2 problems :

The first one (but can be fixed easily)
About the captcha, calling the partial {{ partial '@recaptcha' }} throw me an error cause october cannot find the partial, not sure what the @ prefix mean, but I replaced that code by {{ partial 'forms/recaptcha' SELF = 'contact' }} and I replaced the default component partial by mine. It works.

The second one (cannot be fixed actually without plugin update)
Second problem (more annoying) is about the success message. It's not flexible enought to magically put the result of the partial in a div with specific ID. It would be better to do something like this :

<div id="{{ forms }}_forms_flash">{% partial '@flash.htm' %}</div>

And, in the partial, to add a condition to output nothing if there is nothing to display. (In fact, even the wrapper div could be inside the flash partial to avoid empty div if there is no messages).

{% if flash %}
  <div class="alert alert-{{ type }}">..........
{% endif %}

Like that, I could call my own partial for the flash message using the same way than the captcha, by replacing {% partial '@flash' %} by {% partial 'forms/flash' %}

This is the recommanded way to proceed to move default component markup to custom partial. markup). See documentation about it

from october-plugin-forms.

gwugodevco avatar gwugodevco commented on July 22, 2024

Another way to do use: overriding component's partial as described here

  1. Create directory in your theme's partial directory with the name of your form-component (note: if you alias your form, the directory name should be the alias, I am using 'service_request' as the alias for 'genericForm' so I should create partials/service_request directory under my theme directory))
  2. Create default.htm in that new directory (themes/my-theme/partials/service_request/default.htm)

That should do.

from october-plugin-forms.

 avatar commented on July 22, 2024

Hello,

Thank you for the reply but it does bring answer to the initial problem.

By doing as you suggest, if you have 20 different form, you end with something like this :

form1/default.htm
form2/default.htm
form3/default.htm
form4/default.htm

It's a lot of different folder for the same feature provided by the same plugin ! When you have lots of form, it would be better to have something like this

forms/form1.htm
forms/form2.htm
forms/form3.htm
etc....

There is a solution to group all forms inside one folder as described in my previous post. It's not ideal but it works !

To improve that the solution would be to add en option in the component configuration to let the user choose the filename of the partial they want to use (instead of default.htm) but, by reading the author reply, it seems it's not possible actually with october cms, so I think the issue can be closed.

from october-plugin-forms.

 avatar commented on July 22, 2024

Wow, I will test that and if it works, you are a genius !

from october-plugin-forms.

skydiver avatar skydiver commented on July 22, 2024

This worked for me.

I don't think the plugin needs any modifications because the solution it's at page level.

from october-plugin-forms.

 avatar commented on July 22, 2024

I confirm, it's managed by october core, so it's not an issue related to this module. Could be closed.

from october-plugin-forms.

rangrage avatar rangrage commented on July 22, 2024

@gwugodevco @Alex360hd can you kindly explain how to implement this please?

I have created a file in my theme partials/forms/form1.htm, then I created a CMS page with the genericForm component.

I've aliased the component with 'form1' and on the page I call the component as suggested:

{% component 'forms::form1' %}

But this does not render the form on the page, I've tried aliasing the component as forms::form1 but this give a validation error.

Can you please let me know what I am missing?

Thanks.

from october-plugin-forms.

rangrage avatar rangrage commented on July 22, 2024

@skydiver can you have a look at my comment above and let me know how to do this please?

Thanks for your assistance.

from october-plugin-forms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.