kitchen-site icon indicating copy to clipboard operation
kitchen-site copied to clipboard

Populating other fields in a form when select a field

Open chiacy opened this issue 8 years ago • 6 comments

i have an invoice item form where the item are picked up from job collection. i.e. user to select the job name from the insert invoice item form, then relevant information in invoice item form is filled accordingly, i.e. description, quantity and amount.

Wonder how to achieve this?

chiacy avatar Mar 06 '16 10:03 chiacy

Maybe to set default value to be lookup collection's field for form fields that should be automatically filed.

field:

{
  "name": "description",
  "default": "{{jobs.description}}"
}

perak avatar Mar 06 '16 10:03 perak

Thanks! Will test

Sent from my iPhone

On 6 Mar 2016, at 6:57 PM, Petar Korponaić [email protected] wrote:

Maybe to set default value to be lookup collection's field for form fields that should be automatically filed.

field:

{ "name": "description", "default": "{{jobs.description}}" } — Reply to this email directly or view it on GitHub.

chiacy avatar Mar 06 '16 11:03 chiacy

Hey @chiacy maybe this helps: https://github.com/perak/kitchen-custom-form-field

perak avatar Mar 07 '16 21:03 perak

Great! Will take a look

Sent from my iPhone

On 8 Mar 2016, at 5:07 AM, Petar Korponaić [email protected] wrote:

Hey @chiacy maybe this helps: https://github.com/perak/kitchen-custom-form-field

— Reply to this email directly or view it on GitHub.

chiacy avatar Mar 07 '16 21:03 chiacy

I did the same with an event

"change select[name=productId]": function(event, template) {
  var prodId = $(event.target).val();

  product = Products.findOne(prodId);

  if (product && product.unitPrice) {
    var unitPriceInput = $('input.form-control[name=unitPrice]')[0];
    if (unitPriceInput) {
      unitPriceInput.value = product.unitPrice
    }
  }
}

ps. loving meteor-kitchen. @perak, keep up the good job!

jvp avatar Mar 30 '16 05:03 jvp

Thanks for the tips, will try at my end

Sent from my iPhone

On 30 Mar 2016, at 1:46 PM, jvp [email protected] wrote:

I did the same with an event

"change select[name=productId]": function(event, template) { var prodId = $(event.target).val();

product = Products.findOne(prodId);

if (product && product.unitPrice) { var unitPriceInput = $('input.form-control[name=unitPrice]')[0]; if (unitPriceInput) { unitPriceInput.value = product.unitPrice } } } — You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub

chiacy avatar Mar 30 '16 06:03 chiacy