Update a lightswitch field in Craft CMS 2 How can I edit a lightswitch field in an entries field layout via PHP? This is my current approach

public function actionSponsoredEntriesPriority() {
    $this-&gt;requireAdmin();
    $this-&gt;requireAjaxRequest();
    $success = false;
    $message = Craft::t('Any message from controller');

    $newPriority = craft()-&gt;request-&gt;getPost('newPriority');
    $entryId = craft()-&gt;request-&gt;getPost('entryId');

    $entries = craft()-&gt;entries;

    $entry = $entries-&gt;getEntryById($entryId);

    if ($entry != null) {
        $entry-&gt;getContent()-&gt;setAttributes(array(
            'lightswitchFieldHandle' =&gt; 1
        ));

        $success = $entries-&gt;saveEntry($entry);
        $success == true;
    } else {
        //return null;
        $success = false;
    }
}


But since there are other required fields that are currently empty for this entry I receive the following response


  message: {featureImage: ["Feature Image cannot be blank."], hero: ["Header cannot be blank."]}


I tried to resave the required fields still stuck at matrix field.
Here is code Reset required field


  Error : Correct the errors listed above.


Do i need to update the required field as well or there is a way to bypass while updating a field ?


  Update : Solution as suggested in answer [Update field directly ]


public function actionSponsoredEntriesPriority() {
        // $this-&gt;requireAdmin();
        // $this-&gt;requireAjaxRequest();
        $newPriority = craft()-&gt;request-&gt;getPost('newPriority');
        $entryId = craft()-&gt;request-&gt;getPost('entryId');
        $success = false;
        $message = Craft::t('Any message from controller');

        // entries object
        $entries = craft()-&gt;entries;
        // entries  by id ( $entryId passed by js )
        $entry = $entries-&gt;getEntryById($entryId);

        if ($entry != null) {
                $command = craft()-&gt;db-&gt;createCommand();
                $success = $command-&gt;update(
                    'content', // table name
                    array(
                    'field_lightswitchFieldHandle' =&gt; 1,
                    'field_sponsoredEntriesPriority' =&gt; $newPriority
                    ), // fields
                    'elementId=:id',
                    array(':id'=&gt; $entryId)
                    );
                $message = Craft::t('Priority saved');
                $success == true;
            } else {
            //return null;
            $success = false;
        }
        // send response true/false with message
       if($success == true){
           $this-&gt;returnJson(
            array(
                'success' =&gt; $success,
                'message' =&gt; $message
            ));
       }else{
           $this-&gt;returnJson(
            array(
                'success' =&gt; $success,
                'message' =&gt; $entry-&gt;getErrors()
            ));
       }
    }
If it's only one single field and you want to bypass all Craft validations for required fields you can change the value directly in your database using Yii commands and the update function

function update($table, $columns, $conditions='', $params=array())


$command = craft()-&gt;db-&gt;createCommand();
$command-&gt;update('craft_content', 
    array(
        'field_yourLightSwitchField' =&gt; 1,
    ), 
    'elementId=:id', array(':id'=&gt;1)
);


If you have a multilocale setup you need to include the condition for the correct locale as well