0

I've been trying to develop this PhoneGap app to create a node of a specific type on a Drupal server. I got services installed, created endpoints and all. However when I tried, I got '406: Not acceptable. Illegal operation detected'. When I look at recent logs, I see a 'Not allowed value x' and additional Illegal offset type in isset or empty for all my dropdowns. Any ideas how come?

My HTML

<div id="appHolder">
    <div id="topHolder">
        <div id="logoHolder">
            <img id="logo" src="img/logo.png" />
        </div>
        <div id="titleHolder">Başvuru yap</div>
    </div>
    <div id="contentHolder" class="apply">
        <label for="profilepicture">Profil fotoğrafı</label>
        <input type="file" id="profilepicture" name="field_oyuncu_fotografi_value" />
        <div id="canvasparent">
            <img id="picture" />
            <canvas width="400" height="300" id="canvas"></canvas>
        </div>
        <input type="text" id="name" placeholder="Adı & Soyadı" required name="title" />
        <input type="number" id="tckn" placeholder="TC Kimlik No" required name="field_tc_kimlik_no_value" />
        <select id="sgk" required name="field_sgk_durumu_value">
            <option selected disabled style="display:none">- SGK durumu -</option>
            <option value="devam_ediyor">Devam ediyor</option>
            <option value="emekli">Emekli</option>
        </select>
        <input type="tel" id="tel" placeholder="Telefon" required name="field_telefon_value" />
        <input type="tel" id="tel2" placeholder="Telefon 2" required name="field_telefon2_value" />
        <div class="description">Size ulaşamadığımız durumda ulaşabileceğimiz bir yakınınız</div>
        <input type="text" id="address" placeholder="Adres" required name="field_adres_value" />
        <select id="city" required name="field_yasadigi_sehir_value">
            <option selected disabled style="display:none;">- Yaşadığı şehir -</option>
            <option value="01">Adana</option>
            <option value="02">Adıyaman</option>
            <option value="03">Afyon</option>
            <option value="04">Ağrı</option>
            <option value="05">Amasya</option>
            <option value="06">Ankara</option>
            <option value="07">Antalya</option>
            <option value="08">Artvin</option>
            <option value="09">Aydın</option>
            <option value="10">Balıkesir</option>
            <option value="11">Bilecik</option>
            <option value="12">Bingöl</option>
            <option value="13">Bitlis</option>
            <option value="14">Bolu</option>
            <option value="15">Burdur</option>
            <option value="16">Bursa</option>
            <option value="17">Çanakkale</option>
            <option value="18">Çankırı</option>
            <option value="19">Çorum</option>
            <option value="20">Denizli</option>
            <option value="21">Diyarbakır</option>
            <option value="22">Edirne</option>
            <option value="23">Elazığ</option>
            <option value="24">Erzincan</option>
            <option value="25">Erzurum</option>
            <option value="26">Eskişehir</option>
            <option value="27">Gaziantep</option>
            <option value="28">Giresun</option>
            <option value="29">Gümüşhane</option>
            <option value="30">Hakkari</option>
            <option value="31">Hatay</option>
            <option value="32">Isparta</option>
            <option value="33">Mersin</option>
            <option value="34">İstanbul</option>
            <option value="35">İzmir</option>
            <option value="36">Kars</option>
            <option value="37">Kastamonu</option>
            <option value="38">Kayseri</option>
            <option value="39">Kırklareli</option>
            <option value="40">Kırşehir</option>
            <option value="41">Kocaeli</option>
            <option value="42">Konya</option>
            <option value="43">Kütahya</option>
            <option value="44">Malatya</option>
            <option value="45">Manisa</option>
            <option value="46">K.Maraş</option>
            <option value="47">Mardin</option>
            <option value="48">Muğla</option>
            <option value="49">Muş</option>
            <option value="50">Nevşehir</option>
            <option value="51">Niğde</option>
            <option value="52">Ordu</option>
            <option value="53">Rize</option>
            <option value="54">Sakarya</option>
            <option value="55">Samsun</option>
            <option value="56">Siirt</option>
            <option value="57">Sinop</option>
            <option value="58">Sivas</option>
            <option value="59">Tekirdağ</option>
            <option value="60">Tokat</option>
            <option value="61">Trabzon</option>
            <option value="62">Tunceli</option>
            <option value="63">Şanlıurfa</option>
            <option value="64">Uşak</option>
            <option value="65">Van</option>
            <option value="66">Yozgat</option>
            <option value="67">Zonguldak</option>
            <option value="68">Aksaray</option>
            <option value="69">Bayburt</option>
            <option value="70">Karaman</option>
            <option value="71">Kırıkkale</option>
            <option value="72">Batman</option>
            <option value="73">Şırnak</option>
            <option value="74">Bartın</option>
            <option value="75">Ardahan</option>
            <option value="76">Iğdır</option>
            <option value="77">Yalova</option>
            <option value="78">Karabük</option>
            <option value="79">Kilis</option>
            <option value="80">Osmaniye</option>
        </select>
        <input id="email" type="email" placeholder="E-posta" required name="field_e_posta_value" />
        <select id="gender" required name="field_cinsiyet_value">
            <option selected disabled style="display:none;">- Cinsiyet -</option>
            <option value="bay">Bay</option>
            <option value="bayan">Bayan</option>
        </select>
        <fieldset>
            <legend>Kategorisi</legend>
            <input type="checkbox" id="oyuncu" name="field_kategorisi_value" value="oyuncu">Oyuncu
            <br>
            <input type="checkbox" id="cocuk_oyuncu" name="field_kategorisi_value" value="cocuk_oyuncu">Çocuk oyuncu
            <br>
            <input type="checkbox" id="yardimci_oyuncu" name="field_kategorisi_value" value="yardimci_oyuncu">Yardımcı oyuncu
            <br>
            <input type="checkbox" id="stand_hostesi" name="field_kategorisi_value" value="stand_hostesi">Stand hostesi
            <br>
            <input type="checkbox" id="yesilcam" name="field_kategorisi_value" value="yesilcam">Yeşilçam
            <br>
        </fieldset>
        <label for="dob">Doğum Tarihi</label>
        <input type="date" id="dob" required name="field_dogum_tarihi_value" />
        <select id="height" required name="field_boy_value">
            <option selected disabled style="display:none;">- Boy -</option>
            <option value="150">1.50 - 1.60</option>
            <option value="160">1.61 - 1.70</option>
            <option value="170">1.71 - 1.80</option>
            <option value="180">1.81 - 1.90</option>
            <option value="190">1.91 - 2.00</option>
            <option value="200">2.01 - 2.10</option>
        </select>
        <select id="weight" required name="field_kilo_value">
            <option selected disabled style="display:none;">- Kilo -</option>
            <option value="45">40 - 50</option>
            <option value="55">51 - 60</option>
            <option value="65">61 - 70</option>
            <option value="75">71 - 80</option>
            <option value="85">81 - 90</option>
            <option value="95">91 - 100</option>
            <option value="105">101 - 110</option>
        </select>
        <select id="eyecolour" required name="field_goz_rengi_value" class="chosen-processed">
            <option selected disabled style="display:none;">- Göz rengi -</option>
            <option value="akahve">Açık kahve</option>
            <option value="kkahve">Koyu kahve</option>
            <option value="siyah">Siyah</option>
            <option value="mavi">Mavi</option>
            <option value="yesil">Yeşil</option>
            <option value="ela">Ela</option>
            <option value="gri">Gri</option>
        </select>
        <select id="skincolour" required name="field_ten_rengi_value" class="chosen-processed">
            <option selected disabled style="display:none;">- Ten rengi -</option>
            <option value="esmer">Esmer</option>
            <option value="beyaz">Beyaz</option>
            <option value="siyahi">Siyahi</option>
            <option value="bugday">Buğday</option>
        </select>
        <select id="shoesize" required name="field_ayak_no_value" class="chosen-processed">
            <option selected disabled style="display:none;">- Ayak no -</option>
            <option value="35">35</option>
            <option value="36">36</option>
            <option value="37">37</option>
            <option value="38">38</option>
            <option value="39">39</option>
            <option value="40">40</option>
            <option value="41">41</option>
            <option value="42">42</option>
            <option value="43">43</option>
            <option value="44">44</option>
            <option value="45">45</option>
            <option value="46">46</option>
            <option value="47">47</option>
            <option value="48">48</option>
            <option value="49">49</option>
            <option value="50">50</option>
        </select>
        <select id="education" required name="field_egitim_duzeyi_value" class="chosen-processed">
            <option selected disabled style="display:none;">- Eğitim düzeyi -</option>
            <option value="İlkokul">İlkokul</option>
            <option value="Ortaokul">Ortaokul</option>
            <option value="Lise">Lise</option>
            <option value="Önlisans">Önlisans</option>
            <option value="Lisans">Lisans</option>
            <option value="Yüksek_lisans">Yüksek lisans</option>
            <option value="Doktora">Doktora</option>
        </select>
        <textarea id="training" placeholder="Oyunculuk eğitimleri" rows="3" name="field_oyunculuk_egitimleri_value"></textarea>
        <div class="description">Virgül ile ayırabilirsiniz</div>
        <input type="text" id="languages" placeholder="Diller" required name="field_diller_value" />
        <div class="description">Virgül ile ayırabilirsiniz</div>
        <input type="text" id="skills" placeholder="Beceriler" />
        <div class="description">Virgül ile ayırabilirsiniz</div>
        <input type="text" id="personal" placeholder="Kişisel" required name="field_kisisel_value" />
        <div class="description">Oyuncu hakkında biyografi niteliğinde bilgi</div>
        <legend>Yeni bir fotoğraf ekleyin</legend>
        <input type="file" id="images" />
        <input type="button" id="upload" value="Yükle" required/>
        <table id="prods">
            <tr class="prods">
                <td>
                    <input type="text" class="title" name="field_diskografi_value" placeholder="Yapım adı">
                </td>
                <td>
                    <select id="prodtype" name="field_diskografi[und][0][value]">
                        <option selected disabled style="style:none;">- Yapım türü -</option>
                        <option value="dizi">Dizi</option>
                        <option value="film">Film</option>
                        <option value="klip">Klip</option>
                        <option value="reklam">Reklam</option>
                    </select>
                </td>
                <td>
                    <select id="prodyear" name="field_diskografi[und][0][value]">
                        <option selected disabled style="style:none;">- Yapım yılı -</option>
                        <option value="2015">2015</option>
                        <option value="2014">2014</option>
                        <option value="2013">2013</option>
                        <option value="2012">2012</option>
                        <option value="2011">2011</option>
                        <option value="2010">2010</option>
                        <option value="2009">2009</option>
                        <option value="2008">2008</option>
                        <option value="2007">2007</option>
                        <option value="2006">2006</option>
                        <option value="2005">2005</option>
                        <option value="2004">2004</option>
                        <option value="2003">2003</option>
                        <option value="2002">2002</option>
                        <option value="2001">2001</option>
                        <option value="2000">2000</option>
                        <option value="1999">1999</option>
                        <option value="1998">1998</option>
                        <option value="1997">1997</option>
                        <option value="1996">1996</option>
                        <option value="1995">1995</option>
                        <option value="1994">1994</option>
                        <option value="1993">1993</option>
                        <option value="1992">1992</option>
                        <option value="1991">1991</option>
                        <option value="1990">1990</option>
                        <option value="1989">1989</option>
                        <option value="1988">1988</option>
                        <option value="1987">1987</option>
                        <option value="1986">1986</option>
                        <option value="1985">1985</option>
                        <option value="1984">1984</option>
                        <option value="1983">1983</option>
                        <option value="1982">1982</option>
                        <option value="1981">1981</option>
                        <option value="1980">1980</option>
                        <option value="1979">1979</option>
                        <option value="1978">1978</option>
                        <option value="1977">1977</option>
                        <option value="1976">1976</option>
                        <option value="1975">1975</option>
                        <option value="1974">1974</option>
                        <option value="1973">1973</option>
                        <option value="1972">1972</option>
                        <option value="1971">1971</option>
                        <option value="1970">1970</option>
                        <option value="1969">1969</option>
                        <option value="1968">1968</option>
                        <option value="1967">1967</option>
                        <option value="1966">1966</option>
                        <option value="1965">1965</option>
                        <option value="1964">1964</option>
                        <option value="1963">1963</option>
                        <option value="1962">1962</option>
                        <option value="1961">1961</option>
                        <option value="1960">1960</option>
                    </select>
                </td>
            </tr>
        </table>
        <button id="addmoreprods">Başka bir öğe ekle</button>
        <label>Yer Aldığı Yapımlar</label>
        <label for="videos">Videolar</label>
        <table id="videos">
            <tr class="videos">
                <td>
                    <fieldset>
                        <input type="text" class="videolink" placeholder="Video linki (Youtube, Vimeo)" />
                        <input type="text" class="videodesc" placeholder="Açıklama" />
                        <div class="description">Açıklama alanı aynı zamanda başlık olarak kullanılacaktır.</div>
                        <button id="addmorevideos">Başka bir öğe ekle</button>
                    </fieldset>
                </td>
            </tr>
        </table>
        <input type="checkbox" id="privacy" value="0">
        <label for="privacy">Sayın üyemiz, başvuru formunda yer alan bilgiler, üçüncü şahıslar tarafından görüntülenmeyecektir. Lütfen <a href="inst.html" data-transition="pop" id="inst">başvuru talimatını</a> okuyunuz.</label> <a id="apply" data-role="button" class="hidden">Kaydol</a>

    </div>
    <div id="navHolder">
        <div id="homeHolder">
            <img id="homeBtn" src="img/homeBtn.png" />
        </div>
        <div id="loginHolder">
            <p></p>
        </div>
        <div id="notificationHolder">
            <div id="notification"></div>
            <img id="notificationBtn" src="img/notificationBtn.png" />
        </div>
    </div>
</div>
</div>

My Javascript

$(function () {
    $("#profilepicture").on("change", function (e) {
        var ctx = $("#canvas")[0].getContext('2d');
        var img = new Image;
        img.src = URL.createObjectURL(e.target.files[0]);
        img.onload = function () {
            ctx.drawImage(img, 10, 10, 300, 300);
            $("img").attr("src", img.src);
        }
    });
    $("#addmoreprods").on("click", function () {
        var tr = $(".prods").first().clone();
        tr.find('input').val('');
        $("#prods").append(tr);
    });
    $("#addmorevideos").on("click", function () {
        var tr = $(".videos").first().clone();
        tr.find('input').val('');
        $("#videos").append(tr);
    });
    /*$("#tel").mask("999 999-9999");
    $("#tel2").mask("999 999-9999");*/
    $("#privacy").on("change", function () {
        $("#submit").toggleClass("hidden");
    });
    $("a#inst").on('tap', function (event) {
        window.open('inst.html');
        event.stopPropagation();
    });
    $("#apply").on("click", function () {
        $.ajax({
            url: 'http://www.rejicast.com/services/user/token.json',
            type: 'post',
            dataType: 'json',
            success: function (token) {
                $.ajax({
                    url: 'http://www.rejicast.com/services/create.json',
                    type: 'post',
                    beforeSend: function (r) {
                        r.setRequestHeader("X-CSRF-Token", token.token);
                    },
                    data: 'node[type]=oyuncu&node[status]=0&node[title]=' + encodeURIComponent($("#name").val()) + '&node[language]=und&node[field_tc_kimlik_no][und][0][value]=' + encodeURIComponent($("#tckn").val()) + '&node[field_sgk_durumu][und][0][value]=' + encodeURIComponent($("#sgk option:selected").val()) + '&node[field_telefon][und][0][value]=' + encodeURIComponent($("#tel").val()) + '&node[field_telefon_2][und][0][value]=' + encodeURIComponent($("#tel2").val()) + '&node[field_adres][und][0][value]=' + encodeURIComponent($("#address").val()) + '&node[field_yasadigi_sehir][und][0][value]=' + encodeURIComponent($("#city option:selected").val()) + '&node[field_kategorisi][und][0][value]=' + encodeURIComponent($("input[name='kategori']:checked").val()) + '&node[field_dogum_tarihi][und][0][value]=' + encodeURIComponent($("#dob").val()) + '&node[field_boy][und][0][value]=' + encodeURIComponent($("select#height option:checked").val()) + '&node[field_kilo][und][0][value]=' + encodeURIComponent($("select#weight option:checked").val()) + '&node[field_goz_rengi][und][0][value]=' + encodeURIComponent($("select#eyecolour option:checked").val()) + '&node[field_ten_rengi][und][0][value]=' + encodeURIComponent($("select#skincolour option:checked").val()) + '&node[field_ayak_no][und][0][value]=' + encodeURIComponent($("select#shoesize option:checked").val()) + '&node[field_egitim_duzeyi][und][0][value]=' + encodeURIComponent($("select#education option:checked").val()) + '&node[field_oyunculuk_egitimleri][und][0][value]=' + encodeURIComponent($("#training").val()) + '&node[field_diller][und][0][value]=' + encodeURIComponent($("#languages").val()) + '&node[field_beceriler][und][0][value]=' + encodeURIComponent($("#skills").val()) + '&node[field_kisisel][und][0][value]=' + encodeURIComponent($("#personal").val()) + '&node[field_videolar[und][0][video_url]]=' + encodeURIComponent($(".videolink").val()) + '&node[field_videolar][und][0][description]=' + encodeURIComponent($(".videodesc").val()) + '&node[field_okudum_anladim][und][0][value]=' + encodeURIComponent($(".privacy").is(':checked') ? 1 : 0),
                    success: function () {
                        window.location.href = "thanks.html";
                        /*
               $mobile.changePage("thanks.html", "slideup");
               */
                    },
                    error: function (xhr, status, message) {
                        console.log(message);
                        navigator.notification.alert("Kaydınızı oluşturamadık, daha sonra tekrar deneyin.");
                    }
                });
            }
        });
    });
});

UPDATE: This answer says I must build my form with Form API. Since I can't use it in my PG app, is that a fact?

UPDATE: One of the errors say "Non-allowed value in Yaşadığı şehir field. Based on your comment, please see a screenshot of allowed values of that field. Is that not correct?

screenshot of allowed values list

19
  • 1
    Have you use ajax drop down in your node content form?
    – vgoradiya
    Commented Sep 22, 2015 at 7:17
  • 2
    Oh right, it's probably the age-old simple one - you're providing a value for a select list that isn't in the allowed values for that field. Drupal doesn't let you do that, as it's (correctly) considered an attack
    – Clive
    Commented Sep 25, 2015 at 12:52
  • 3
    @Clive you were right, node[field_yasadigi_sehir][und][value] worked :) If you could make that comment an answer, I want to accept it.
    – Kartagis
    Commented Sep 25, 2015 at 19:16
  • 1
    Okay, but please make that an answer if nobody comes along and explains.
    – Kartagis
    Commented Sep 25, 2015 at 21:22
  • 2
    I will, just don't want to put off anyone else who has a better answer by seeing the checkmark next to it. If no one answers in a few days (or by the time I've worked it out) I'll put an answer in
    – Clive
    Commented Sep 25, 2015 at 21:43

1 Answer 1

0
+150

List fields can sometimes be a pain. Hopefully one day I'll work out why and update this, but in the meantime try addressing the field like this:

node[field_yasadigi_sehir][und][value]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.