Skip Navigation

[Resolved] Two edit forms on one page

This support ticket is created 4 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 8 replies, has 2 voices.

Last updated by JakubV7709 4 years, 8 months ago.

Assisted by: Waqar.

Author
Posts
#1597577

Hi,

i have a Custom post type (Company) and i allow my customers to publish this company via front-end credform and then edit througt edit form which is on the same page. It works perfectly.

I would like to set a second edit form on the same page, because this will allow to my customer pay for better position in my directory on website. I´m using hidden field with number for save different value on my other posts and works too perfectly.

So i created a second edit form, which is chargeable (instead of the first edit form which is free to edit by author), add this new editing form the current post, but the submit button doesn´t work. There is a correct setting that this form will forward my customer to checkout page, but the button is disabled for unknow reason.

The first edit form (for free)

[wpv-conditional if="( empty($[types usermeta='logospolecnosti' output='raw' current_user='true']) )"]
<label><strong>Vložte logo v sekci Upravit můj profil</strong><br>
<em>Bez vložení loga společnosti není možné vkládat příspěvky</em></label>
[/wpv-conditional]

[wpv-conditional if="( '[types usermeta='logospolecnosti' output='raw' current_user='true']' ne '' )"]

[credform]
<div class="container-fluid">
<div id="formula">			[cred_field field="form_messages" class="alert alert-warning" style="font-family:quicksand; font-size:15px; font-weight:500; color: red"]

  <div class="row" style="margin-bottom: 20px">
 <a style="font-size:18px;font-weight:600;font-family:quicksand;"> <img src="<em><u>hidden link</u></em>"> Zde můžete upravit znění článku, vyměnit fotografie či upravit další informace. Již zveřejněný příspěvek se nachází pod formulářem pro úpravu.</a>
     </div>
<div class="form-group">
          <div style="display: none;">
		<label>Název firemního profilu:</label>
		[cred_field field='post_title' class='form-control' input_type="hidden" value="[types usermeta='spolecnost' current_user='true'][/types]" output='bootstrap']
	</div>	</div>

<div class="row">
		<div class="form-group col-sm-6">
		<label>Představte společnost pro potencionální zákazníky:</label>
		[cred_field field="post_excerpt" force_type="field" class="form-control" placeholder="Uveďte krátký popis čím se zabýváte a jaká je Vaše specializace" output="bootstrap"]
  <a style="font-family: quicksand; font-size: 10px; color: white;">Omezený počet znaků pro toto pole:<div id="chars" style="font-family: quicksand; font-size: 10px; color: red;">200</div></a>
		</div>
    <div class="col-sm-1"></div>

  <div class="col-sm-4">
  		<div class="form-group" id="boxy" style="border:1px solid white;border-radius:8px;padding:10px;">
		<label>Na jaké typy společností se specializujete?<img alt="Pro přehlednější uživatelské rozhraní je omezení výběru na 3 položky. Vyberte prosím pečlivě Vaše specializace." title="Pro přehlednější uživatelské rozhraní je omezení výběru na 3 položky. Vyberte prosím pečlivě Vaše specializace." src="<em><u>hidden link</u></em>"></label>
		[cred_field field="obor" force_type="taxonomy" output="bootstrap" display="checkbox"]
	</div>	</div>


</div>


  <div class="row">

          <div class="form-group col-sm-6">
		<label>Adresa společnosti:</label>
		[cred_field field="adresa-spolecnosti" force_type="field" class="form-control" placeholder="Vložte adresu / Případně přidejte pobočky" output="bootstrap"]
	</div>
        <div class="col-sm-1"></div>
		<div class="col-sm-4"><div class="form-group">
<label>Datum založení společnosti:</label>
		[cred_field field="datum-zalozeni-spolecnosti" force_type="field" class="form-control" placeholder="Uveďte rok založení společnosti" output="bootstrap"]
	</div>
<div class="form-group">
<label>Počet zaměstnanců:</label>
		[cred_field field="pocet-zamestnancu" force_type="field" class="form-control" placeholder="Uveďte počet zaměstnanců" output="bootstrap"]
</div>
<div class="form-group">
<label>E-mailový kontakt pro zájemce:</label>
		[cred_field field="kontaktni-firemni-email" force_type="field" class="form-control" placeholder="Kontakt pro poptávky ze strany klientů" output="bootstrap"]
</div>
    <div class="form-group">
	<label>Telefonní kontakt pro zájemce:</label>
		[cred_field field="kontaktni-telefonni-cislo" force_type="field" class="form-control" placeholder="Kontakt pro poptávky ze strany klientů" output="bootstrap"]
</div>  
              <div class="form-group">
	<label>Logo společnosti:</label>
                [cred_field field='logo-spolecnosti' force_type='field' class='form-control' output='bootstrap' preview='filename']
</div>  

</div></div>


<div class="row">
	<div class="col-sm-3"><div class="form-group">
		<label>Jaké služby v ICT poskytujete?<img alt="Pro přehlednější uživatelské rozhraní je omezení výběru na 10 položek. Vyberte prosím pečlivě Vaše specializace." title="Pro přehlednější uživatelské rozhraní je omezení výběru na 10 položky. Vyberte prosím pečlivě Vaše specializace." src="<em><u>hidden link</u></em>"></label>
		[cred_field field="sluzba" force_type="taxonomy" output="bootstrap" display="checkbox"]
	</div></div>
	<div class="col-sm-3" id="boxy"><div class="form-group">
		<label>Jaké řešení dokážete nabídnout?<img alt="Pro přehlednější uživatelské rozhraní je omezení výběru na 5 položek. Vyberte prosím pečlivě Vaše specializace." title="Pro přehlednější uživatelské rozhraní je omezení výběru na 5 položek. Vyberte prosím pečlivě Vaše specializace." src="<em><u>hidden link</u></em>"></label>
		[cred_field field="firemni-reseni" force_type="taxonomy" output="bootstrap" display="checkbox"]
	</div></div>
	
  <div class="col-sm-3" id="boxy"><div class="form-group">
		<label>Jaké výrobce nabízíte?</label>
[cred_field field='vyrobce' force_type='taxonomy' output='bootstrap' display='checkbox']
[cred_field field="vyrobce_add_new" taxonomy="vyrobce" type="add_new"]
	</div></div>
  <div class="col-sm-3" id="boxy"><div class="form-group">
<div class="vyrobceform">
		<label>Jaké máte certifikace a partnerství?</label>
[cred_field field='partner-level' force_type='taxonomy' output='bootstrap' display='checkbox' class='myzebra']</div>
[cred_field field="partner-level_add_new" taxonomy="partner-level" type="add_new"]
	</div></div>
</div>
			[cred_field field="form_messages" class="alert alert-warning" style="font-family:quicksand; font-size:15px; font-weight:500; color: red"]

	<div class="row">
		<div class="col-sm-12">
         <center>[cred_field field='form_submit' output='bootstrap' value='Potvrdit úpravy' class='button']</center>
			
		</div>
	</div>
	</div>
</div>
[/credform]

[/wpv-conditional]


The second edit form (charge for edit)

[credform]
	[cred_field field='form_messages' class='alert alert-warning']

 <div class="row" style="display: none">
		<div class="col-sm-12">
          [cred_field field='placeny-firemni-profil' force_type='field' class='form-control' output='bootstrap' value='1']
   </div>
	</div>

 <div class="col-sm-6">
    	<label>Zvolte délku zvýhodnění:</label>
[cred_generic_field type='select' field='reklama' class='form-control']
{
"required":0,
"persist":1,
"default":["4677"],
"options":[{"value":"4677","label":"790,- kč - zvýhodnění na 3 měsíce"},{"value":"6494","label":"1590,- Kč - zvýhodnění na 6 měsíců"}]
}
[/cred_generic_field]
		</div>

	[cred_field field='form_submit' output='bootstrap' value='Přejít k pokladně' class='btn btn-primary btn-lg']
[/credform]
#1598465

Hi,

Thank you for contacting us and I'd be happy to assist.

To troubleshoot this, I'll need to see exactly how these forms are set up in the admin area.

Can you please share temporary admin login details, along with the link to a page with these forms?

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.

regards,
Waqar

#1602361

Hi,

i had to change my password - please change last two characters to 10 (insted of 09).

#1602375

Could you please give an advice about another thing in this case?

In my new form (for free) is default value for hidden custom field "placeny-firemni-profil" to number 2. There is a same new form (for money) which is set to number 1 and post expired based on the days (i have got this in functions.php).

That means I can easily filter in result page where the post with custom field value 2 are on the bottom and with value 1 is always on the top in results.

Is there a way that if some choose new form (for free, post expiration is not set) and after xx days he use edit form where will be my second form which is not working yer to change value instead of number 2 to number 1 (that means his post will be on the top of result page) and after xxx days (based on the post-expired) this value will be change back to number 2?

/** Form expiration date by product id*/
add_action('cred_save_data', 'my_save_data_action',999,2);
function my_save_data_action($post_id, $form_data){
    // if a specific form
    if ($form_data['id']==4681){
 
        //get the value from the field as it appears in the post with the ID from above and assign it to a variable
        $product_id = get_post_meta($post_id, 'reklama', true);
         
        if($product_id == 4677){
                $timestamp = current_time('timestamp') + 180 * DAY_IN_SECONDS;
     
            }else if($product_id == 4682){
                $timestamp = current_time('timestamp') + 365 * DAY_IN_SECONDS;
          
            }
        update_post_meta($post_id, '_cred_post_expiration_time',  $timestamp);
    }
      if ($form_data['id']==4925){
 
        //get the value from the field as it appears in the post with the ID from above and assign it to a variable
        $product_id = get_post_meta($post_id, 'reklama', true);
         
        if($product_id == 6493){
                $timestamp = current_time('timestamp') + 90 * DAY_IN_SECONDS;
     
            }else if($product_id == 6494){
                $timestamp = current_time('timestamp') + 180 * DAY_IN_SECONDS;
          
            }
        update_post_meta($post_id, '_cred_post_expiration_time',  $timestamp);
    }
   }

Thank you for your support.

#1602609

Thank you for sharing the admin access and these additional details.

I'm currently performing some tests with a similar form set up on my test website and will share my findings as soon as this testing completes.

Thank you for your patience.

#1604565

Hi,

Thank you for waiting while I performed some troubleshooting.

The customer user login details that you've shared were not working, so I had to register as a test customer.
( user: test@waqar.xyz & Firemní profil: test company )

When viewing the company profile edit page with the two edit forms, I noticed a custom script error in the browser's console, which is resulting in the disabled submit button for the second edit form.
( screenshot: hidden link )

If the custom script from the "Edit form firemní profil" form is removed, the submit button becomes enabled. You can update that custom script accordingly to avoid this.

As for the second question about changing the custom field value(s) when a post expires, you can use "cred_post_expiration_custom_actions" filter:
https://toolset.com/documentation/user-guides/front-end-forms/automatic-post-expiration/#what-happens-when-posts-expire

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1604795

Hi Waqar,

i updated login details in private message to give you acces to my wp-admin.

I updated a part what you highlighted (delete scripts) too and everything works fine for me. There shouldn´t be impact to function of Toolset.

Anyway could you please check it again in backend? Forms (id 5512 and 6497). It really works only with one edit form on this page. I really appreciate to have two edit form on one page (one will send you to checkout and one will allow my customers edit their post).

Thank you for question to my second question and i will follow your instruction about that.

#1606825

Hi,

Thanks for writing back and I can confirm that I can use both the edit forms ( at hidden link ) and they work as expected when I remove the following custom script blocks from the form "Edit form firemní profil":


(function($) {
    $.fn.extend( {
        limiter: function(limit, elem) {
            $(this).on("keyup focus", function() {
                setCount(this, elem);
            });
            function setCount(src, elem) {
                var chars = src.value.length;
                if (chars > limit) {
                    src.value = src.value.substr(0, limit);
                    chars = limit;
                }
                elem.html( limit - chars );
            }
            setCount($(this)[0], elem);
        }
    });
})(jQuery);
  
jQuery(document).on('cred_form_ready', function(){
var elem = jQuery("#chars");
jQuery('input[name="post_excerpt"]').limiter(350, elem);
});

Can you please test both those forms after removing those script blocks?

regards,
Waqar

#1609775

My issue is resolved now. Thank you!