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

cant populate my dropdown value field with values from my collection

Open Maqhosha opened this issue 9 years ago • 10 comments

my collection looks like this. { "name": "tblCountry", "type": "collection", "fields": [ { "name": "cCountryName", "title": "Country Name", "type": "string", "required": true }, { "name": "cCountryCode", "title": "Country Code", "type": "string" } ], "roles_allowed_to_read": [ "nobody" ], "roles_allowed_to_insert": [ "owner" ], "roles_allowed_to_update": [ "owner" ] }, but its not working, please help, actually it looks like all my collection are not working, cause i even fill my dataview, sorry i'm new to meteor-kitchen

Maqhosha avatar Mar 08 '16 06:03 Maqhosha

@Maqhosha your collection looks good. What doesn't work? Do you have any error messages?

Maybe problem can be in naming convention: kitchen expects object names in "snake case" (instead tblCountry should be tbl_country, and the same for field names). Kitchen will properly generate your collection, but if you refer collection from another object (form, dataview etc.) by "camel case" name "tblCountry" then generator will not find it because name is internally stored in "snake case".

Maybe that's solution for your issue? Just convert all object names to "snake_case" and let me know.

perak avatar Mar 08 '16 06:03 perak

@perak I don’t get any errors maybe its the naming conversion. that means i must change everything from my project. Thank you i wil get back to you.

Maqhosha avatar Mar 08 '16 07:03 Maqhosha

is this the right way to get values form the collection to a select field?

        </div>

Maqhosha avatar Mar 08 '16 08:03 Maqhosha

@Maqhosha If you are using "kitchen", there is "lookup field" in a form (see "example-invoices") - it will show data from the collection in select box in a form.

If you are doing manually (writing code without "kitchen"), correct way is:

<select name="countryId">
    {{#each countries}}
        <option value="{{_id}}">{{cCountryName}}</option>
    {{/each}}
</select>

perak avatar Mar 08 '16 09:03 perak

I think am going there thank you. but ist a must to use params?

Maqhosha avatar Mar 08 '16 10:03 Maqhosha

my problem is solved thank you perak, now i have a little problem on my private layout my routing is not working i cant access my pages

Maqhosha avatar Mar 09 '16 07:03 Maqhosha

@Maqhosha I cannot help you that way - you need to describe problem in details and give me steps to reproduce.

perak avatar Mar 09 '16 08:03 perak

okay here the peace of code, am now doing some touch ups meteor. when i add the new subscribe like that of sports_personality my page load forever, or am not allowed to add anything here other than the generated code?

isReady: function() {

    var subs = [
        Meteor.subscribe("countries"),
        //Meteor.subscribe("sports_personality"),
        Meteor.subscribe("teams"),
        Meteor.subscribe("sports"),
        Meteor.subscribe("players"),
        Meteor.subscribe("current_user_data")
    ];
    var ready = true;
    _.each(subs, function(sub) {
        if(!sub.ready())
            ready = false;
    });
    return ready;
},

data: function() {

    return {
        params: this.params || {},
        countries: TblCountry.find({}, {}),
        sports_personality: TblSportsPerson.find({}, {}),
        teams: TblTeams.find({}, {}),
        sports: TblSports.find({}, {}),
        players: TblPlayers.find({}, {}),
        current_user_data: Users.findOne({_id:Meteor.userId()}, {})
    };

Maqhosha avatar Mar 09 '16 09:03 Maqhosha

Do you have server-side publish code for these? ("sports_personality", "teams", ... ) ?

perak avatar Mar 09 '16 09:03 perak

@perak oh thank you everything is working fine now, the naming was different and i removed the if statement and returned only the TblSportsPerson.find... i thought "nobody" means everyone can access the collection but since i removed everything is working fine
Meteor.publish("sports_person", function() { if(Users.isInRoles(this.userId, ["nobody"])) { return TblSportsPerson.find({}, {}); } return this.ready(); }); thank you very much perak :+1:

Maqhosha avatar Mar 09 '16 11:03 Maqhosha